documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * 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.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * 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).
  161. * 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.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @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.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Extracts text content from a DOM element hierarchy
  283. * @param element defines the root element
  284. * @returns a string
  285. */
  286. static GetDOMTextContent(element: HTMLElement): string;
  287. }
  288. }
  289. declare module BABYLON {
  290. /**
  291. * Logger used througouht the application to allow configuration of
  292. * the log level required for the messages.
  293. */
  294. export class Logger {
  295. /**
  296. * No log
  297. */
  298. static readonly NoneLogLevel: number;
  299. /**
  300. * Only message logs
  301. */
  302. static readonly MessageLogLevel: number;
  303. /**
  304. * Only warning logs
  305. */
  306. static readonly WarningLogLevel: number;
  307. /**
  308. * Only error logs
  309. */
  310. static readonly ErrorLogLevel: number;
  311. /**
  312. * All logs
  313. */
  314. static readonly AllLogLevel: number;
  315. private static _LogCache;
  316. /**
  317. * Gets a value indicating the number of loading errors
  318. * @ignorenaming
  319. */
  320. static errorsCount: number;
  321. /**
  322. * Callback called when a new log is added
  323. */
  324. static OnNewCacheEntry: (entry: string) => void;
  325. private static _AddLogEntry;
  326. private static _FormatMessage;
  327. private static _LogDisabled;
  328. private static _LogEnabled;
  329. private static _WarnDisabled;
  330. private static _WarnEnabled;
  331. private static _ErrorDisabled;
  332. private static _ErrorEnabled;
  333. /**
  334. * Log a message to the console
  335. */
  336. static Log: (message: string) => void;
  337. /**
  338. * Write a warning message to the console
  339. */
  340. static Warn: (message: string) => void;
  341. /**
  342. * Write an error message to the console
  343. */
  344. static Error: (message: string) => void;
  345. /**
  346. * Gets current log cache (list of logs)
  347. */
  348. static readonly LogCache: string;
  349. /**
  350. * Clears the log cache
  351. */
  352. static ClearLogCache(): void;
  353. /**
  354. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  355. */
  356. static LogLevels: number;
  357. }
  358. }
  359. declare module BABYLON {
  360. /** @hidden */
  361. export class _TypeStore {
  362. /** @hidden */
  363. static RegisteredTypes: {
  364. [key: string]: Object;
  365. };
  366. /** @hidden */
  367. static GetClass(fqdn: string): any;
  368. }
  369. }
  370. declare module BABYLON {
  371. /**
  372. * Class containing a set of static utilities functions for deep copy.
  373. */
  374. export class DeepCopier {
  375. /**
  376. * Tries to copy an object by duplicating every property
  377. * @param source defines the source object
  378. * @param destination defines the target object
  379. * @param doNotCopyList defines a list of properties to avoid
  380. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  381. */
  382. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  383. }
  384. }
  385. declare module BABYLON {
  386. /**
  387. * Class containing a set of static utilities functions for precision date
  388. */
  389. export class PrecisionDate {
  390. /**
  391. * Gets either window.performance.now() if supported or Date.now() else
  392. */
  393. static readonly Now: number;
  394. }
  395. }
  396. declare module BABYLON {
  397. /** @hidden */
  398. export class _DevTools {
  399. static WarnImport(name: string): string;
  400. }
  401. }
  402. declare module BABYLON {
  403. /**
  404. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  405. */
  406. export class WebRequest {
  407. private _xhr;
  408. /**
  409. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  410. * i.e. when loading files, where the server/service expects an Authorization header
  411. */
  412. static CustomRequestHeaders: {
  413. [key: string]: string;
  414. };
  415. /**
  416. * Add callback functions in this array to update all the requests before they get sent to the network
  417. */
  418. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  419. private _injectCustomRequestHeaders;
  420. /**
  421. * Gets or sets a function to be called when loading progress changes
  422. */
  423. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  424. /**
  425. * Returns client's state
  426. */
  427. readonly readyState: number;
  428. /**
  429. * Returns client's status
  430. */
  431. readonly status: number;
  432. /**
  433. * Returns client's status as a text
  434. */
  435. readonly statusText: string;
  436. /**
  437. * Returns client's response
  438. */
  439. readonly response: any;
  440. /**
  441. * Returns client's response url
  442. */
  443. readonly responseURL: string;
  444. /**
  445. * Returns client's response as text
  446. */
  447. readonly responseText: string;
  448. /**
  449. * Gets or sets the expected response type
  450. */
  451. responseType: XMLHttpRequestResponseType;
  452. /** @hidden */
  453. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  454. /** @hidden */
  455. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  456. /**
  457. * Cancels any network activity
  458. */
  459. abort(): void;
  460. /**
  461. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  462. * @param body defines an optional request body
  463. */
  464. send(body?: Document | BodyInit | null): void;
  465. /**
  466. * Sets the request method, request URL
  467. * @param method defines the method to use (GET, POST, etc..)
  468. * @param url defines the url to connect with
  469. */
  470. open(method: string, url: string): void;
  471. }
  472. }
  473. declare module BABYLON {
  474. /**
  475. * File request interface
  476. */
  477. export interface IFileRequest {
  478. /**
  479. * Raised when the request is complete (success or error).
  480. */
  481. onCompleteObservable: Observable<IFileRequest>;
  482. /**
  483. * Aborts the request for a file.
  484. */
  485. abort: () => void;
  486. }
  487. }
  488. declare module BABYLON {
  489. /**
  490. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  491. */
  492. export class PerformanceMonitor {
  493. private _enabled;
  494. private _rollingFrameTime;
  495. private _lastFrameTimeMs;
  496. /**
  497. * constructor
  498. * @param frameSampleSize The number of samples required to saturate the sliding window
  499. */
  500. constructor(frameSampleSize?: number);
  501. /**
  502. * Samples current frame
  503. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  504. */
  505. sampleFrame(timeMs?: number): void;
  506. /**
  507. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  508. */
  509. readonly averageFrameTime: number;
  510. /**
  511. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTimeVariance: number;
  514. /**
  515. * Returns the frame time of the most recent frame
  516. */
  517. readonly instantaneousFrameTime: number;
  518. /**
  519. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  520. */
  521. readonly averageFPS: number;
  522. /**
  523. * Returns the average framerate in frames per second using the most recent frame time
  524. */
  525. readonly instantaneousFPS: number;
  526. /**
  527. * Returns true if enough samples have been taken to completely fill the sliding window
  528. */
  529. readonly isSaturated: boolean;
  530. /**
  531. * Enables contributions to the sliding window sample set
  532. */
  533. enable(): void;
  534. /**
  535. * Disables contributions to the sliding window sample set
  536. * Samples will not be interpolated over the disabled period
  537. */
  538. disable(): void;
  539. /**
  540. * Returns true if sampling is enabled
  541. */
  542. readonly isEnabled: boolean;
  543. /**
  544. * Resets performance monitor
  545. */
  546. reset(): void;
  547. }
  548. /**
  549. * RollingAverage
  550. *
  551. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  552. */
  553. export class RollingAverage {
  554. /**
  555. * Current average
  556. */
  557. average: number;
  558. /**
  559. * Current variance
  560. */
  561. variance: number;
  562. protected _samples: Array<number>;
  563. protected _sampleCount: number;
  564. protected _pos: number;
  565. protected _m2: number;
  566. /**
  567. * constructor
  568. * @param length The number of samples required to saturate the sliding window
  569. */
  570. constructor(length: number);
  571. /**
  572. * Adds a sample to the sample set
  573. * @param v The sample value
  574. */
  575. add(v: number): void;
  576. /**
  577. * Returns previously added values or null if outside of history or outside the sliding window domain
  578. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  579. * @return Value previously recorded with add() or null if outside of range
  580. */
  581. history(i: number): number;
  582. /**
  583. * Returns true if enough samples have been taken to completely fill the sliding window
  584. * @return true if sample-set saturated
  585. */
  586. isSaturated(): boolean;
  587. /**
  588. * Resets the rolling average (equivalent to 0 samples taken so far)
  589. */
  590. reset(): void;
  591. /**
  592. * Wraps a value around the sample range boundaries
  593. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  594. * @return Wrapped position in sample range
  595. */
  596. protected _wrapPosition(i: number): number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /**
  601. * This class implement a typical dictionary using a string as key and the generic type T as value.
  602. * The underlying implementation relies on an associative array to ensure the best performances.
  603. * The value can be anything including 'null' but except 'undefined'
  604. */
  605. export class StringDictionary<T> {
  606. /**
  607. * This will clear this dictionary and copy the content from the 'source' one.
  608. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  609. * @param source the dictionary to take the content from and copy to this dictionary
  610. */
  611. copyFrom(source: StringDictionary<T>): void;
  612. /**
  613. * Get a value based from its key
  614. * @param key the given key to get the matching value from
  615. * @return the value if found, otherwise undefined is returned
  616. */
  617. get(key: string): T | undefined;
  618. /**
  619. * Get a value from its key or add it if it doesn't exist.
  620. * This method will ensure you that a given key/data will be present in the dictionary.
  621. * @param key the given key to get the matching value from
  622. * @param factory the factory that will create the value if the key is not present in the dictionary.
  623. * The factory will only be invoked if there's no data for the given key.
  624. * @return the value corresponding to the key.
  625. */
  626. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  627. /**
  628. * Get a value from its key if present in the dictionary otherwise add it
  629. * @param key the key to get the value from
  630. * @param val if there's no such key/value pair in the dictionary add it with this value
  631. * @return the value corresponding to the key
  632. */
  633. getOrAdd(key: string, val: T): T;
  634. /**
  635. * Check if there's a given key in the dictionary
  636. * @param key the key to check for
  637. * @return true if the key is present, false otherwise
  638. */
  639. contains(key: string): boolean;
  640. /**
  641. * Add a new key and its corresponding value
  642. * @param key the key to add
  643. * @param value the value corresponding to the key
  644. * @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
  645. */
  646. add(key: string, value: T): boolean;
  647. /**
  648. * Update a specific value associated to a key
  649. * @param key defines the key to use
  650. * @param value defines the value to store
  651. * @returns true if the value was updated (or false if the key was not found)
  652. */
  653. set(key: string, value: T): boolean;
  654. /**
  655. * Get the element of the given key and remove it from the dictionary
  656. * @param key defines the key to search
  657. * @returns the value associated with the key or null if not found
  658. */
  659. getAndRemove(key: string): Nullable<T>;
  660. /**
  661. * Remove a key/value from the dictionary.
  662. * @param key the key to remove
  663. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  664. */
  665. remove(key: string): boolean;
  666. /**
  667. * Clear the whole content of the dictionary
  668. */
  669. clear(): void;
  670. /**
  671. * Gets the current count
  672. */
  673. readonly count: number;
  674. /**
  675. * Execute a callback on each key/val of the dictionary.
  676. * Note that you can remove any element in this dictionary in the callback implementation
  677. * @param callback the callback to execute on a given key/value pair
  678. */
  679. forEach(callback: (key: string, val: T) => void): void;
  680. /**
  681. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  682. * If the callback returns null or undefined the method will iterate to the next key/value pair
  683. * Note that you can remove any element in this dictionary in the callback implementation
  684. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  685. * @returns the first item
  686. */
  687. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  688. private _count;
  689. private _data;
  690. }
  691. }
  692. declare module BABYLON {
  693. /**
  694. * Class used to store gfx data (like WebGLBuffer)
  695. */
  696. export class DataBuffer {
  697. /**
  698. * Gets or sets the number of objects referencing this buffer
  699. */
  700. references: number;
  701. /** Gets or sets the size of the underlying buffer */
  702. capacity: number;
  703. /**
  704. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  705. */
  706. is32Bits: boolean;
  707. /**
  708. * Gets the underlying buffer
  709. */
  710. readonly underlyingResource: any;
  711. }
  712. }
  713. declare module BABYLON {
  714. /**
  715. * Class used to store data that will be store in GPU memory
  716. */
  717. export class Buffer {
  718. private _engine;
  719. private _buffer;
  720. /** @hidden */
  721. _data: Nullable<DataArray>;
  722. private _updatable;
  723. private _instanced;
  724. /**
  725. * Gets the byte stride.
  726. */
  727. readonly byteStride: number;
  728. /**
  729. * Constructor
  730. * @param engine the engine
  731. * @param data the data to use for this buffer
  732. * @param updatable whether the data is updatable
  733. * @param stride the stride (optional)
  734. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  735. * @param instanced whether the buffer is instanced (optional)
  736. * @param useBytes set to true if the stride in in bytes (optional)
  737. */
  738. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  739. /**
  740. * Create a new VertexBuffer based on the current buffer
  741. * @param kind defines the vertex buffer kind (position, normal, etc.)
  742. * @param offset defines offset in the buffer (0 by default)
  743. * @param size defines the size in floats of attributes (position is 3 for instance)
  744. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  745. * @param instanced defines if the vertex buffer contains indexed data
  746. * @param useBytes defines if the offset and stride are in bytes
  747. * @returns the new vertex buffer
  748. */
  749. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  750. /**
  751. * Gets a boolean indicating if the Buffer is updatable?
  752. * @returns true if the buffer is updatable
  753. */
  754. isUpdatable(): boolean;
  755. /**
  756. * Gets current buffer's data
  757. * @returns a DataArray or null
  758. */
  759. getData(): Nullable<DataArray>;
  760. /**
  761. * Gets underlying native buffer
  762. * @returns underlying native buffer
  763. */
  764. getBuffer(): Nullable<DataBuffer>;
  765. /**
  766. * Gets the stride in float32 units (i.e. byte stride / 4).
  767. * May not be an integer if the byte stride is not divisible by 4.
  768. * DEPRECATED. Use byteStride instead.
  769. * @returns the stride in float32 units
  770. */
  771. getStrideSize(): number;
  772. /**
  773. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  774. * @param data defines the data to store
  775. */
  776. create(data?: Nullable<DataArray>): void;
  777. /** @hidden */
  778. _rebuild(): void;
  779. /**
  780. * Update current buffer data
  781. * @param data defines the data to store
  782. */
  783. update(data: DataArray): void;
  784. /**
  785. * Updates the data directly.
  786. * @param data the new data
  787. * @param offset the new offset
  788. * @param vertexCount the vertex count (optional)
  789. * @param useBytes set to true if the offset is in bytes
  790. */
  791. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  792. /**
  793. * Release all resources
  794. */
  795. dispose(): void;
  796. }
  797. /**
  798. * Specialized buffer used to store vertex data
  799. */
  800. export class VertexBuffer {
  801. /** @hidden */
  802. _buffer: Buffer;
  803. private _kind;
  804. private _size;
  805. private _ownsBuffer;
  806. private _instanced;
  807. private _instanceDivisor;
  808. /**
  809. * The byte type.
  810. */
  811. static readonly BYTE: number;
  812. /**
  813. * The unsigned byte type.
  814. */
  815. static readonly UNSIGNED_BYTE: number;
  816. /**
  817. * The short type.
  818. */
  819. static readonly SHORT: number;
  820. /**
  821. * The unsigned short type.
  822. */
  823. static readonly UNSIGNED_SHORT: number;
  824. /**
  825. * The integer type.
  826. */
  827. static readonly INT: number;
  828. /**
  829. * The unsigned integer type.
  830. */
  831. static readonly UNSIGNED_INT: number;
  832. /**
  833. * The float type.
  834. */
  835. static readonly FLOAT: number;
  836. /**
  837. * Gets or sets the instance divisor when in instanced mode
  838. */
  839. instanceDivisor: number;
  840. /**
  841. * Gets the byte stride.
  842. */
  843. readonly byteStride: number;
  844. /**
  845. * Gets the byte offset.
  846. */
  847. readonly byteOffset: number;
  848. /**
  849. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  850. */
  851. readonly normalized: boolean;
  852. /**
  853. * Gets the data type of each component in the array.
  854. */
  855. readonly type: number;
  856. /**
  857. * Constructor
  858. * @param engine the engine
  859. * @param data the data to use for this vertex buffer
  860. * @param kind the vertex buffer kind
  861. * @param updatable whether the data is updatable
  862. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  863. * @param stride the stride (optional)
  864. * @param instanced whether the buffer is instanced (optional)
  865. * @param offset the offset of the data (optional)
  866. * @param size the number of components (optional)
  867. * @param type the type of the component (optional)
  868. * @param normalized whether the data contains normalized data (optional)
  869. * @param useBytes set to true if stride and offset are in bytes (optional)
  870. */
  871. 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);
  872. /** @hidden */
  873. _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * 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".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * 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"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */
  2379. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2380. /**
  2381. * Unproject from screen space to object space
  2382. * @param source defines the screen space Vector3 to use
  2383. * @param viewportWidth defines the current width of the viewport
  2384. * @param viewportHeight defines the current height of the viewport
  2385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2386. * @param transform defines the transform (view x projection) matrix to use
  2387. * @returns the new Vector3
  2388. */
  2389. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param view defines the view matrix to use
  2397. * @param projection defines the projection matrix to use
  2398. * @returns the new Vector3
  2399. */
  2400. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2401. /**
  2402. * Unproject from screen space to object space
  2403. * @param source defines the screen space Vector3 to use
  2404. * @param viewportWidth defines the current width of the viewport
  2405. * @param viewportHeight defines the current height of the viewport
  2406. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2407. * @param view defines the view matrix to use
  2408. * @param projection defines the projection matrix to use
  2409. * @param result defines the Vector3 where to store the result
  2410. */
  2411. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param sourceX defines the screen space x coordinate to use
  2415. * @param sourceY defines the screen space y coordinate to use
  2416. * @param sourceZ defines the screen space z coordinate to use
  2417. * @param viewportWidth defines the current width of the viewport
  2418. * @param viewportHeight defines the current height of the viewport
  2419. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2420. * @param view defines the view matrix to use
  2421. * @param projection defines the projection matrix to use
  2422. * @param result defines the Vector3 where to store the result
  2423. */
  2424. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2425. /**
  2426. * Gets the minimal coordinate values between two Vector3
  2427. * @param left defines the first operand
  2428. * @param right defines the second operand
  2429. * @returns the new Vector3
  2430. */
  2431. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Gets the maximal coordinate values between two Vector3
  2434. * @param left defines the first operand
  2435. * @param right defines the second operand
  2436. * @returns the new Vector3
  2437. */
  2438. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2439. /**
  2440. * Returns the distance between the vectors "value1" and "value2"
  2441. * @param value1 defines the first operand
  2442. * @param value2 defines the second operand
  2443. * @returns the distance
  2444. */
  2445. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2446. /**
  2447. * Returns the squared distance between the vectors "value1" and "value2"
  2448. * @param value1 defines the first operand
  2449. * @param value2 defines the second operand
  2450. * @returns the squared distance
  2451. */
  2452. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2453. /**
  2454. * Returns a new Vector3 located at the center between "value1" and "value2"
  2455. * @param value1 defines the first operand
  2456. * @param value2 defines the second operand
  2457. * @returns the new Vector3
  2458. */
  2459. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2462. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2463. * to something in order to rotate it from its local system to the given target system
  2464. * Note: axis1, axis2 and axis3 are normalized during this operation
  2465. * @param axis1 defines the first axis
  2466. * @param axis2 defines the second axis
  2467. * @param axis3 defines the third axis
  2468. * @returns a new Vector3
  2469. */
  2470. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2471. /**
  2472. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2473. * @param axis1 defines the first axis
  2474. * @param axis2 defines the second axis
  2475. * @param axis3 defines the third axis
  2476. * @param ref defines the Vector3 where to store the result
  2477. */
  2478. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2479. }
  2480. /**
  2481. * Vector4 class created for EulerAngle class conversion to Quaternion
  2482. */
  2483. export class Vector4 {
  2484. /** x value of the vector */
  2485. x: number;
  2486. /** y value of the vector */
  2487. y: number;
  2488. /** z value of the vector */
  2489. z: number;
  2490. /** w value of the vector */
  2491. w: number;
  2492. /**
  2493. * Creates a Vector4 object from the given floats.
  2494. * @param x x value of the vector
  2495. * @param y y value of the vector
  2496. * @param z z value of the vector
  2497. * @param w w value of the vector
  2498. */
  2499. constructor(
  2500. /** x value of the vector */
  2501. x: number,
  2502. /** y value of the vector */
  2503. y: number,
  2504. /** z value of the vector */
  2505. z: number,
  2506. /** w value of the vector */
  2507. w: number);
  2508. /**
  2509. * Returns the string with the Vector4 coordinates.
  2510. * @returns a string containing all the vector values
  2511. */
  2512. toString(): string;
  2513. /**
  2514. * Returns the string "Vector4".
  2515. * @returns "Vector4"
  2516. */
  2517. getClassName(): string;
  2518. /**
  2519. * Returns the Vector4 hash code.
  2520. * @returns a unique hash code
  2521. */
  2522. getHashCode(): number;
  2523. /**
  2524. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2525. * @returns the resulting array
  2526. */
  2527. asArray(): number[];
  2528. /**
  2529. * Populates the given array from the given index with the Vector4 coordinates.
  2530. * @param array array to populate
  2531. * @param index index of the array to start at (default: 0)
  2532. * @returns the Vector4.
  2533. */
  2534. toArray(array: FloatArray, index?: number): Vector4;
  2535. /**
  2536. * Adds the given vector to the current Vector4.
  2537. * @param otherVector the vector to add
  2538. * @returns the updated Vector4.
  2539. */
  2540. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @returns the resulting vector
  2545. */
  2546. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2547. /**
  2548. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2549. * @param otherVector the vector to add
  2550. * @param result the vector to store the result
  2551. * @returns the current Vector4.
  2552. */
  2553. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2554. /**
  2555. * Subtract in place the given vector from the current Vector4.
  2556. * @param otherVector the vector to subtract
  2557. * @returns the updated Vector4.
  2558. */
  2559. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to add
  2563. * @returns the new vector with the result
  2564. */
  2565. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2566. /**
  2567. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @param result the vector to store the result
  2570. * @returns the current Vector4.
  2571. */
  2572. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2573. /**
  2574. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2575. */
  2576. /**
  2577. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2578. * @param x value to subtract
  2579. * @param y value to subtract
  2580. * @param z value to subtract
  2581. * @param w value to subtract
  2582. * @returns new vector containing the result
  2583. */
  2584. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2585. /**
  2586. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. * @param x value to subtract
  2588. * @param y value to subtract
  2589. * @param z value to subtract
  2590. * @param w value to subtract
  2591. * @param result the vector to store the result in
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2597. * @returns a new vector with the negated values
  2598. */
  2599. negate(): Vector4;
  2600. /**
  2601. * Multiplies the current Vector4 coordinates by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns the updated Vector4.
  2604. */
  2605. scaleInPlace(scale: number): Vector4;
  2606. /**
  2607. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @returns a new vector with the result
  2610. */
  2611. scale(scale: number): Vector4;
  2612. /**
  2613. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2614. * @param scale the number to scale with
  2615. * @param result a vector to store the result in
  2616. * @returns the current Vector4.
  2617. */
  2618. scaleToRef(scale: number, result: Vector4): Vector4;
  2619. /**
  2620. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Vector4 object where to store the result
  2623. * @returns the unmodified current Vector4
  2624. */
  2625. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2628. * @param otherVector the vector to compare against
  2629. * @returns true if they are equal
  2630. */
  2631. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2632. /**
  2633. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2634. * @param otherVector vector to compare against
  2635. * @param epsilon (Default: very small number)
  2636. * @returns true if they are equal
  2637. */
  2638. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2639. /**
  2640. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2641. * @param x x value to compare against
  2642. * @param y y value to compare against
  2643. * @param z z value to compare against
  2644. * @param w w value to compare against
  2645. * @returns true if equal
  2646. */
  2647. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2648. /**
  2649. * Multiplies in place the current Vector4 by the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns the updated Vector4.
  2652. */
  2653. multiplyInPlace(otherVector: Vector4): Vector4;
  2654. /**
  2655. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @returns resulting new vector
  2658. */
  2659. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2660. /**
  2661. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @param result vector to store the result
  2664. * @returns the current Vector4.
  2665. */
  2666. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2667. /**
  2668. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2669. * @param x x value multiply with
  2670. * @param y y value multiply with
  2671. * @param z z value multiply with
  2672. * @param w w value multiply with
  2673. * @returns resulting new vector
  2674. */
  2675. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @returns resulting new vector
  2680. */
  2681. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2684. * @param otherVector vector to devide with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Divides the current Vector3 coordinates by the given ones.
  2691. * @param otherVector vector to devide with
  2692. * @returns the updated Vector3.
  2693. */
  2694. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector4
  2705. */
  2706. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Gets a new Vector4 from current Vector4 floored values
  2709. * @returns a new Vector4
  2710. */
  2711. floor(): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector3 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. fract(): Vector4;
  2717. /**
  2718. * Returns the Vector4 length (float).
  2719. * @returns the length
  2720. */
  2721. length(): number;
  2722. /**
  2723. * Returns the Vector4 squared length (float).
  2724. * @returns the length squared
  2725. */
  2726. lengthSquared(): number;
  2727. /**
  2728. * Normalizes in place the Vector4.
  2729. * @returns the updated Vector4.
  2730. */
  2731. normalize(): Vector4;
  2732. /**
  2733. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2734. * @returns this converted to a new vector3
  2735. */
  2736. toVector3(): Vector3;
  2737. /**
  2738. * Returns a new Vector4 copied from the current one.
  2739. * @returns the new cloned vector
  2740. */
  2741. clone(): Vector4;
  2742. /**
  2743. * Updates the current Vector4 with the given one coordinates.
  2744. * @param source the source vector to copy from
  2745. * @returns the updated Vector4.
  2746. */
  2747. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2748. /**
  2749. * Updates the current Vector4 coordinates with the given floats.
  2750. * @param x float to copy from
  2751. * @param y float to copy from
  2752. * @param z float to copy from
  2753. * @param w float to copy from
  2754. * @returns the updated Vector4.
  2755. */
  2756. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2757. /**
  2758. * Updates the current Vector4 coordinates with the given floats.
  2759. * @param x float to set from
  2760. * @param y float to set from
  2761. * @param z float to set from
  2762. * @param w float to set from
  2763. * @returns the updated Vector4.
  2764. */
  2765. set(x: number, y: number, z: number, w: number): Vector4;
  2766. /**
  2767. * Copies the given float to the current Vector3 coordinates
  2768. * @param v defines the x, y, z and w coordinates of the operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. setAll(v: number): Vector4;
  2772. /**
  2773. * Returns a new Vector4 set from the starting index of the given array.
  2774. * @param array the array to pull values from
  2775. * @param offset the offset into the array to start at
  2776. * @returns the new vector
  2777. */
  2778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2779. /**
  2780. * Updates the given vector "result" from the starting index of the given array.
  2781. * @param array the array to pull values from
  2782. * @param offset the offset into the array to start at
  2783. * @param result the vector to store the result in
  2784. */
  2785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2786. /**
  2787. * Updates the given vector "result" from the starting index of the given Float32Array.
  2788. * @param array the array to pull values from
  2789. * @param offset the offset into the array to start at
  2790. * @param result the vector to store the result in
  2791. */
  2792. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2793. /**
  2794. * Updates the given vector "result" coordinates from the given floats.
  2795. * @param x float to set from
  2796. * @param y float to set from
  2797. * @param z float to set from
  2798. * @param w float to set from
  2799. * @param result the vector to the floats in
  2800. */
  2801. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2802. /**
  2803. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2804. * @returns the new vector
  2805. */
  2806. static Zero(): Vector4;
  2807. /**
  2808. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2809. * @returns the new vector
  2810. */
  2811. static One(): Vector4;
  2812. /**
  2813. * Returns a new normalized Vector4 from the given one.
  2814. * @param vector the vector to normalize
  2815. * @returns the vector
  2816. */
  2817. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2818. /**
  2819. * Updates the given vector "result" from the normalization of the given one.
  2820. * @param vector the vector to normalize
  2821. * @param result the vector to store the result in
  2822. */
  2823. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2824. /**
  2825. * Returns a vector with the minimum values from the left and right vectors
  2826. * @param left left vector to minimize
  2827. * @param right right vector to minimize
  2828. * @returns a new vector with the minimum of the left and right vector values
  2829. */
  2830. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2831. /**
  2832. * Returns a vector with the maximum values from the left and right vectors
  2833. * @param left left vector to maximize
  2834. * @param right right vector to maximize
  2835. * @returns a new vector with the maximum of the left and right vector values
  2836. */
  2837. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2838. /**
  2839. * Returns the distance (float) between the vectors "value1" and "value2".
  2840. * @param value1 value to calulate the distance between
  2841. * @param value2 value to calulate the distance between
  2842. * @return the distance between the two vectors
  2843. */
  2844. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2845. /**
  2846. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2847. * @param value1 value to calulate the distance between
  2848. * @param value2 value to calulate the distance between
  2849. * @return the distance between the two vectors squared
  2850. */
  2851. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2852. /**
  2853. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2854. * @param value1 value to calulate the center between
  2855. * @param value2 value to calulate the center between
  2856. * @return the center between the two vectors
  2857. */
  2858. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2859. /**
  2860. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2861. * This methods computes transformed normalized direction vectors only.
  2862. * @param vector the vector to transform
  2863. * @param transformation the transformation matrix to apply
  2864. * @returns the new vector
  2865. */
  2866. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2867. /**
  2868. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2869. * This methods computes transformed normalized direction vectors only.
  2870. * @param vector the vector to transform
  2871. * @param transformation the transformation matrix to apply
  2872. * @param result the vector to store the result in
  2873. */
  2874. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2875. /**
  2876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2877. * This methods computes transformed normalized direction vectors only.
  2878. * @param x value to transform
  2879. * @param y value to transform
  2880. * @param z value to transform
  2881. * @param w value to transform
  2882. * @param transformation the transformation matrix to apply
  2883. * @param result the vector to store the results in
  2884. */
  2885. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2886. /**
  2887. * Creates a new Vector4 from a Vector3
  2888. * @param source defines the source data
  2889. * @param w defines the 4th component (default is 0)
  2890. * @returns a new Vector4
  2891. */
  2892. static FromVector3(source: Vector3, w?: number): Vector4;
  2893. }
  2894. /**
  2895. * Class used to store quaternion data
  2896. * @see https://en.wikipedia.org/wiki/Quaternion
  2897. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2898. */
  2899. export class Quaternion {
  2900. /** defines the first component (0 by default) */
  2901. x: number;
  2902. /** defines the second component (0 by default) */
  2903. y: number;
  2904. /** defines the third component (0 by default) */
  2905. z: number;
  2906. /** defines the fourth component (1.0 by default) */
  2907. w: number;
  2908. /**
  2909. * Creates a new Quaternion from the given floats
  2910. * @param x defines the first component (0 by default)
  2911. * @param y defines the second component (0 by default)
  2912. * @param z defines the third component (0 by default)
  2913. * @param w defines the fourth component (1.0 by default)
  2914. */
  2915. constructor(
  2916. /** defines the first component (0 by default) */
  2917. x?: number,
  2918. /** defines the second component (0 by default) */
  2919. y?: number,
  2920. /** defines the third component (0 by default) */
  2921. z?: number,
  2922. /** defines the fourth component (1.0 by default) */
  2923. w?: number);
  2924. /**
  2925. * Gets a string representation for the current quaternion
  2926. * @returns a string with the Quaternion coordinates
  2927. */
  2928. toString(): string;
  2929. /**
  2930. * Gets the class name of the quaternion
  2931. * @returns the string "Quaternion"
  2932. */
  2933. getClassName(): string;
  2934. /**
  2935. * Gets a hash code for this quaternion
  2936. * @returns the quaternion hash code
  2937. */
  2938. getHashCode(): number;
  2939. /**
  2940. * Copy the quaternion to an array
  2941. * @returns a new array populated with 4 elements from the quaternion coordinates
  2942. */
  2943. asArray(): number[];
  2944. /**
  2945. * Check if two quaternions are equals
  2946. * @param otherQuaternion defines the second operand
  2947. * @return true if the current quaternion and the given one coordinates are strictly equals
  2948. */
  2949. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2950. /**
  2951. * Clone the current quaternion
  2952. * @returns a new quaternion copied from the current one
  2953. */
  2954. clone(): Quaternion;
  2955. /**
  2956. * Copy a quaternion to the current one
  2957. * @param other defines the other quaternion
  2958. * @returns the updated current quaternion
  2959. */
  2960. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2961. /**
  2962. * Updates the current quaternion with the given float coordinates
  2963. * @param x defines the x coordinate
  2964. * @param y defines the y coordinate
  2965. * @param z defines the z coordinate
  2966. * @param w defines the w coordinate
  2967. * @returns the updated current quaternion
  2968. */
  2969. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2970. /**
  2971. * Updates the current quaternion from the given float coordinates
  2972. * @param x defines the x coordinate
  2973. * @param y defines the y coordinate
  2974. * @param z defines the z coordinate
  2975. * @param w defines the w coordinate
  2976. * @returns the updated current quaternion
  2977. */
  2978. set(x: number, y: number, z: number, w: number): Quaternion;
  2979. /**
  2980. * Adds two quaternions
  2981. * @param other defines the second operand
  2982. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2983. */
  2984. add(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Add a quaternion to the current one
  2987. * @param other defines the quaternion to add
  2988. * @returns the current quaternion
  2989. */
  2990. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2991. /**
  2992. * Subtract two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the subtraction result of the given one from the current one
  2995. */
  2996. subtract(other: Quaternion): Quaternion;
  2997. /**
  2998. * Multiplies the current quaternion by a scale factor
  2999. * @param value defines the scale factor
  3000. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3001. */
  3002. scale(value: number): Quaternion;
  3003. /**
  3004. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3005. * @param scale defines the scale factor
  3006. * @param result defines the Quaternion object where to store the result
  3007. * @returns the unmodified current quaternion
  3008. */
  3009. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3010. /**
  3011. * Multiplies in place the current quaternion by a scale factor
  3012. * @param value defines the scale factor
  3013. * @returns the current modified quaternion
  3014. */
  3015. scaleInPlace(value: number): Quaternion;
  3016. /**
  3017. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3018. * @param scale defines the scale factor
  3019. * @param result defines the Quaternion object where to store the result
  3020. * @returns the unmodified current quaternion
  3021. */
  3022. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3023. /**
  3024. * Multiplies two quaternions
  3025. * @param q1 defines the second operand
  3026. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3027. */
  3028. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3029. /**
  3030. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3031. * @param q1 defines the second operand
  3032. * @param result defines the target quaternion
  3033. * @returns the current quaternion
  3034. */
  3035. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3036. /**
  3037. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3038. * @param q1 defines the second operand
  3039. * @returns the currentupdated quaternion
  3040. */
  3041. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3042. /**
  3043. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3044. * @param ref defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. conjugateToRef(ref: Quaternion): Quaternion;
  3048. /**
  3049. * Conjugates in place (1-q) the current quaternion
  3050. * @returns the current updated quaternion
  3051. */
  3052. conjugateInPlace(): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns a new quaternion
  3056. */
  3057. conjugate(): Quaternion;
  3058. /**
  3059. * Gets length of current quaternion
  3060. * @returns the quaternion length (float)
  3061. */
  3062. length(): number;
  3063. /**
  3064. * Normalize in place the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. normalize(): Quaternion;
  3068. /**
  3069. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3070. * @param order is a reserved parameter and is ignore for now
  3071. * @returns a new Vector3 containing the Euler angles
  3072. */
  3073. toEulerAngles(order?: string): Vector3;
  3074. /**
  3075. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3076. * @param result defines the vector which will be filled with the Euler angles
  3077. * @param order is a reserved parameter and is ignore for now
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toEulerAnglesToRef(result: Vector3): Quaternion;
  3081. /**
  3082. * Updates the given rotation matrix with the current quaternion values
  3083. * @param result defines the target matrix
  3084. * @returns the current unchanged quaternion
  3085. */
  3086. toRotationMatrix(result: Matrix): Quaternion;
  3087. /**
  3088. * Updates the current quaternion from the given rotation matrix values
  3089. * @param matrix defines the source matrix
  3090. * @returns the current updated quaternion
  3091. */
  3092. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Creates a new quaternion from a rotation matrix
  3095. * @param matrix defines the source matrix
  3096. * @returns a new quaternion created from the given rotation matrix values
  3097. */
  3098. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3099. /**
  3100. * Updates the given quaternion with the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @param result defines the target quaternion
  3103. */
  3104. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3105. /**
  3106. * Returns the dot product (float) between the quaternions "left" and "right"
  3107. * @param left defines the left operand
  3108. * @param right defines the right operand
  3109. * @returns the dot product
  3110. */
  3111. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3112. /**
  3113. * Checks if the two quaternions are close to each other
  3114. * @param quat0 defines the first quaternion to check
  3115. * @param quat1 defines the second quaternion to check
  3116. * @returns true if the two quaternions are close to each other
  3117. */
  3118. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3119. /**
  3120. * Creates an empty quaternion
  3121. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3122. */
  3123. static Zero(): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @returns a new quaternion as the inverted current quaternion
  3128. */
  3129. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3130. /**
  3131. * Inverse a given quaternion
  3132. * @param q defines the source quaternion
  3133. * @param result the quaternion the result will be stored in
  3134. * @returns the result quaternion
  3135. */
  3136. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3137. /**
  3138. * Creates an identity quaternion
  3139. * @returns the identity quaternion
  3140. */
  3141. static Identity(): Quaternion;
  3142. /**
  3143. * Gets a boolean indicating if the given quaternion is identity
  3144. * @param quaternion defines the quaternion to check
  3145. * @returns true if the quaternion is identity
  3146. */
  3147. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3148. /**
  3149. * Creates a quaternion from a rotation around an axis
  3150. * @param axis defines the axis to use
  3151. * @param angle defines the angle to use
  3152. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3153. */
  3154. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3155. /**
  3156. * Creates a rotation around an axis and stores it into the given quaternion
  3157. * @param axis defines the axis to use
  3158. * @param angle defines the angle to use
  3159. * @param result defines the target quaternion
  3160. * @returns the target quaternion
  3161. */
  3162. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3163. /**
  3164. * Creates a new quaternion from data stored into an array
  3165. * @param array defines the data source
  3166. * @param offset defines the offset in the source array where the data starts
  3167. * @returns a new quaternion
  3168. */
  3169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3170. /**
  3171. * Create a quaternion from Euler rotation angles
  3172. * @param x Pitch
  3173. * @param y Yaw
  3174. * @param z Roll
  3175. * @returns the new Quaternion
  3176. */
  3177. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3178. /**
  3179. * Updates a quaternion from Euler rotation angles
  3180. * @param x Pitch
  3181. * @param y Yaw
  3182. * @param z Roll
  3183. * @param result the quaternion to store the result
  3184. * @returns the updated quaternion
  3185. */
  3186. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3187. /**
  3188. * Create a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation vector
  3195. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3196. * @param result the quaternion to store the result
  3197. * @returns the updated quaternion
  3198. */
  3199. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3200. /**
  3201. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3202. * @param yaw defines the rotation around Y axis
  3203. * @param pitch defines the rotation around X axis
  3204. * @param roll defines the rotation around Z axis
  3205. * @returns the new quaternion
  3206. */
  3207. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3208. /**
  3209. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3210. * @param yaw defines the rotation around Y axis
  3211. * @param pitch defines the rotation around X axis
  3212. * @param roll defines the rotation around Z axis
  3213. * @param result defines the target quaternion
  3214. */
  3215. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3216. /**
  3217. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3218. * @param alpha defines the rotation around first axis
  3219. * @param beta defines the rotation around second axis
  3220. * @param gamma defines the rotation around third axis
  3221. * @returns the new quaternion
  3222. */
  3223. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3224. /**
  3225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3226. * @param alpha defines the rotation around first axis
  3227. * @param beta defines the rotation around second axis
  3228. * @param gamma defines the rotation around third axis
  3229. * @param result defines the target quaternion
  3230. */
  3231. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3232. /**
  3233. * 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)
  3234. * @param axis1 defines the first axis
  3235. * @param axis2 defines the second axis
  3236. * @param axis3 defines the third axis
  3237. * @returns the new quaternion
  3238. */
  3239. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3240. /**
  3241. * 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
  3242. * @param axis1 defines the first axis
  3243. * @param axis2 defines the second axis
  3244. * @param axis3 defines the third axis
  3245. * @param ref defines the target quaternion
  3246. */
  3247. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3248. /**
  3249. * Interpolates between two quaternions
  3250. * @param left defines first quaternion
  3251. * @param right defines second quaternion
  3252. * @param amount defines the gradient to use
  3253. * @returns the new interpolated quaternion
  3254. */
  3255. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3256. /**
  3257. * Interpolates between two quaternions and stores it into a target quaternion
  3258. * @param left defines first quaternion
  3259. * @param right defines second quaternion
  3260. * @param amount defines the gradient to use
  3261. * @param result defines the target quaternion
  3262. */
  3263. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3264. /**
  3265. * Interpolate between two quaternions using Hermite interpolation
  3266. * @param value1 defines first quaternion
  3267. * @param tangent1 defines the incoming tangent
  3268. * @param value2 defines second quaternion
  3269. * @param tangent2 defines the outgoing tangent
  3270. * @param amount defines the target quaternion
  3271. * @returns the new interpolated quaternion
  3272. */
  3273. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3274. }
  3275. /**
  3276. * Class used to store matrix data (4x4)
  3277. */
  3278. export class Matrix {
  3279. private static _updateFlagSeed;
  3280. private static _identityReadOnly;
  3281. private _isIdentity;
  3282. private _isIdentityDirty;
  3283. private _isIdentity3x2;
  3284. private _isIdentity3x2Dirty;
  3285. /**
  3286. * Gets the update flag of the matrix which is an unique number for the matrix.
  3287. * It will be incremented every time the matrix data change.
  3288. * You can use it to speed the comparison between two versions of the same matrix.
  3289. */
  3290. updateFlag: number;
  3291. private readonly _m;
  3292. /**
  3293. * Gets the internal data of the matrix
  3294. */
  3295. readonly m: DeepImmutable<Float32Array>;
  3296. /** @hidden */
  3297. _markAsUpdated(): void;
  3298. /** @hidden */
  3299. private _updateIdentityStatus;
  3300. /**
  3301. * Creates an empty matrix (filled with zeros)
  3302. */
  3303. constructor();
  3304. /**
  3305. * Check if the current matrix is identity
  3306. * @returns true is the matrix is the identity matrix
  3307. */
  3308. isIdentity(): boolean;
  3309. /**
  3310. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentityAs3x2(): boolean;
  3314. /**
  3315. * Gets the determinant of the matrix
  3316. * @returns the matrix determinant
  3317. */
  3318. determinant(): number;
  3319. /**
  3320. * Returns the matrix as a Float32Array
  3321. * @returns the matrix underlying array
  3322. */
  3323. toArray(): DeepImmutable<Float32Array>;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array.
  3327. */
  3328. asArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Inverts the current matrix in place
  3331. * @returns the current inverted matrix
  3332. */
  3333. invert(): Matrix;
  3334. /**
  3335. * Sets all the matrix elements to zero
  3336. * @returns the current matrix
  3337. */
  3338. reset(): Matrix;
  3339. /**
  3340. * Adds the current matrix with a second one
  3341. * @param other defines the matrix to add
  3342. * @returns a new matrix as the addition of the current matrix and the given one
  3343. */
  3344. add(other: DeepImmutable<Matrix>): Matrix;
  3345. /**
  3346. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3347. * @param other defines the matrix to add
  3348. * @param result defines the target matrix
  3349. * @returns the current matrix
  3350. */
  3351. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3352. /**
  3353. * Adds in place the given matrix to the current matrix
  3354. * @param other defines the second operand
  3355. * @returns the current updated matrix
  3356. */
  3357. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3358. /**
  3359. * Sets the given matrix to the current inverted Matrix
  3360. * @param other defines the target matrix
  3361. * @returns the unmodified current matrix
  3362. */
  3363. invertToRef(other: Matrix): Matrix;
  3364. /**
  3365. * add a value at the specified position in the current Matrix
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): Matrix;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * @param x defines the 1st component of the translation
  3381. * @param y defines the 2nd component of the translation
  3382. * @param z defines the 3rd component of the translation
  3383. * @returns the current updated matrix
  3384. */
  3385. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3386. /**
  3387. * Adds the translation vector (using 3 floats) in the current matrix
  3388. * @param x defines the 1st component of the translation
  3389. * @param y defines the 2nd component of the translation
  3390. * @param z defines the 3rd component of the translation
  3391. * @returns the current updated matrix
  3392. */
  3393. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3394. /**
  3395. * Inserts the translation vector in the current matrix
  3396. * @param vector3 defines the translation to insert
  3397. * @returns the current updated matrix
  3398. */
  3399. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3400. /**
  3401. * Gets the translation value of the current matrix
  3402. * @returns a new Vector3 as the extracted translation from the matrix
  3403. */
  3404. getTranslation(): Vector3;
  3405. /**
  3406. * Fill a Vector3 with the extracted translation from the matrix
  3407. * @param result defines the Vector3 where to store the translation
  3408. * @returns the current matrix
  3409. */
  3410. getTranslationToRef(result: Vector3): Matrix;
  3411. /**
  3412. * Remove rotation and scaling part from the matrix
  3413. * @returns the updated matrix
  3414. */
  3415. removeRotationAndScaling(): Matrix;
  3416. /**
  3417. * Multiply two matrices
  3418. * @param other defines the second operand
  3419. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3420. */
  3421. multiply(other: DeepImmutable<Matrix>): Matrix;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * @param other defines the source matrix
  3425. * @returns the current updated matrix
  3426. */
  3427. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3428. /**
  3429. * Populates the given array from the starting index with the current matrix values
  3430. * @param array defines the target array
  3431. * @param offset defines the offset in the target array where to start storing values
  3432. * @returns the current matrix
  3433. */
  3434. copyToArray(array: Float32Array, offset?: number): Matrix;
  3435. /**
  3436. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the matrix where to store the multiplication
  3439. * @returns the current matrix
  3440. */
  3441. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3442. /**
  3443. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3444. * @param other defines the second operand
  3445. * @param result defines the array where to store the multiplication
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3450. /**
  3451. * Check equality between this matrix and a second one
  3452. * @param value defines the second matrix to compare
  3453. * @returns true is the current matrix and the given one values are strictly equal
  3454. */
  3455. equals(value: DeepImmutable<Matrix>): boolean;
  3456. /**
  3457. * Clone the current matrix
  3458. * @returns a new matrix from the current matrix
  3459. */
  3460. clone(): Matrix;
  3461. /**
  3462. * Returns the name of the current matrix class
  3463. * @returns the string "Matrix"
  3464. */
  3465. getClassName(): string;
  3466. /**
  3467. * Gets the hash code of the current matrix
  3468. * @returns the hash code
  3469. */
  3470. getHashCode(): number;
  3471. /**
  3472. * Decomposes the current Matrix into a translation, rotation and scaling components
  3473. * @param scale defines the scale vector3 given as a reference to update
  3474. * @param rotation defines the rotation quaternion given as a reference to update
  3475. * @param translation defines the translation vector3 given as a reference to update
  3476. * @returns true if operation was successful
  3477. */
  3478. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3479. /**
  3480. * Gets specific row of the matrix
  3481. * @param index defines the number of the row to get
  3482. * @returns the index-th row of the current matrix as a new Vector4
  3483. */
  3484. getRow(index: number): Nullable<Vector4>;
  3485. /**
  3486. * Sets the index-th row of the current matrix to the vector4 values
  3487. * @param index defines the number of the row to set
  3488. * @param row defines the target vector4
  3489. * @returns the updated current matrix
  3490. */
  3491. setRow(index: number, row: Vector4): Matrix;
  3492. /**
  3493. * Compute the transpose of the matrix
  3494. * @returns the new transposed matrix
  3495. */
  3496. transpose(): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix and store it in a given matrix
  3499. * @param result defines the target matrix
  3500. * @returns the current matrix
  3501. */
  3502. transposeToRef(result: Matrix): Matrix;
  3503. /**
  3504. * Sets the index-th row of the current matrix with the given 4 x float values
  3505. * @param index defines the row index
  3506. * @param x defines the x component to set
  3507. * @param y defines the y component to set
  3508. * @param z defines the z component to set
  3509. * @param w defines the w component to set
  3510. * @returns the updated current matrix
  3511. */
  3512. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3513. /**
  3514. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3515. * @param scale defines the scale factor
  3516. * @returns a new matrix
  3517. */
  3518. scale(scale: number): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor to a given result matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Scale the current matrix values by a factor and add the result to a given matrix
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Matrix to store the result
  3530. * @returns the current matrix
  3531. */
  3532. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3533. /**
  3534. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3535. * @param ref matrix to store the result
  3536. */
  3537. toNormalMatrix(ref: Matrix): void;
  3538. /**
  3539. * Gets only rotation part of the current matrix
  3540. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3541. */
  3542. getRotationMatrix(): Matrix;
  3543. /**
  3544. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3545. * @param result defines the target matrix to store data to
  3546. * @returns the current matrix
  3547. */
  3548. getRotationMatrixToRef(result: Matrix): Matrix;
  3549. /**
  3550. * Toggles model matrix from being right handed to left handed in place and vice versa
  3551. */
  3552. toggleModelMatrixHandInPlace(): void;
  3553. /**
  3554. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3555. */
  3556. toggleProjectionMatrixHandInPlace(): void;
  3557. /**
  3558. * Creates a matrix from an array
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @returns a new Matrix set from the starting index of the given array
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3564. /**
  3565. * Copy the content of an array into a given matrix
  3566. * @param array defines the source array
  3567. * @param offset defines an offset in the source array
  3568. * @param result defines the target matrix
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3571. /**
  3572. * Stores an array into a matrix after having multiplied each component by a given factor
  3573. * @param array defines the source array
  3574. * @param offset defines the offset in the source array
  3575. * @param scale defines the scaling factor
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3579. /**
  3580. * Gets an identity matrix that must not be updated
  3581. */
  3582. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3583. /**
  3584. * Stores a list of values (16) inside a given matrix
  3585. * @param initialM11 defines 1st value of 1st row
  3586. * @param initialM12 defines 2nd value of 1st row
  3587. * @param initialM13 defines 3rd value of 1st row
  3588. * @param initialM14 defines 4th value of 1st row
  3589. * @param initialM21 defines 1st value of 2nd row
  3590. * @param initialM22 defines 2nd value of 2nd row
  3591. * @param initialM23 defines 3rd value of 2nd row
  3592. * @param initialM24 defines 4th value of 2nd row
  3593. * @param initialM31 defines 1st value of 3rd row
  3594. * @param initialM32 defines 2nd value of 3rd row
  3595. * @param initialM33 defines 3rd value of 3rd row
  3596. * @param initialM34 defines 4th value of 3rd row
  3597. * @param initialM41 defines 1st value of 4th row
  3598. * @param initialM42 defines 2nd value of 4th row
  3599. * @param initialM43 defines 3rd value of 4th row
  3600. * @param initialM44 defines 4th value of 4th row
  3601. * @param result defines the target matrix
  3602. */
  3603. 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;
  3604. /**
  3605. * Creates new matrix from a list of values (16)
  3606. * @param initialM11 defines 1st value of 1st row
  3607. * @param initialM12 defines 2nd value of 1st row
  3608. * @param initialM13 defines 3rd value of 1st row
  3609. * @param initialM14 defines 4th value of 1st row
  3610. * @param initialM21 defines 1st value of 2nd row
  3611. * @param initialM22 defines 2nd value of 2nd row
  3612. * @param initialM23 defines 3rd value of 2nd row
  3613. * @param initialM24 defines 4th value of 2nd row
  3614. * @param initialM31 defines 1st value of 3rd row
  3615. * @param initialM32 defines 2nd value of 3rd row
  3616. * @param initialM33 defines 3rd value of 3rd row
  3617. * @param initialM34 defines 4th value of 3rd row
  3618. * @param initialM41 defines 1st value of 4th row
  3619. * @param initialM42 defines 2nd value of 4th row
  3620. * @param initialM43 defines 3rd value of 4th row
  3621. * @param initialM44 defines 4th value of 4th row
  3622. * @returns the new matrix
  3623. */
  3624. 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;
  3625. /**
  3626. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3627. * @param scale defines the scale vector3
  3628. * @param rotation defines the rotation quaternion
  3629. * @param translation defines the translation vector3
  3630. * @returns a new matrix
  3631. */
  3632. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3633. /**
  3634. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3635. * @param scale defines the scale vector3
  3636. * @param rotation defines the rotation quaternion
  3637. * @param translation defines the translation vector3
  3638. * @param result defines the target matrix
  3639. */
  3640. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * Creates a new identity matrix
  3643. * @returns a new identity matrix
  3644. */
  3645. static Identity(): Matrix;
  3646. /**
  3647. * Creates a new identity matrix and stores the result in a given matrix
  3648. * @param result defines the target matrix
  3649. */
  3650. static IdentityToRef(result: Matrix): void;
  3651. /**
  3652. * Creates a new zero matrix
  3653. * @returns a new zero matrix
  3654. */
  3655. static Zero(): Matrix;
  3656. /**
  3657. * Creates a new rotation matrix for "angle" radians around the X axis
  3658. * @param angle defines the angle (in radians) to use
  3659. * @return the new matrix
  3660. */
  3661. static RotationX(angle: number): Matrix;
  3662. /**
  3663. * Creates a new matrix as the invert of a given matrix
  3664. * @param source defines the source matrix
  3665. * @returns the new matrix
  3666. */
  3667. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3670. * @param angle defines the angle (in radians) to use
  3671. * @param result defines the target matrix
  3672. */
  3673. static RotationXToRef(angle: number, result: Matrix): void;
  3674. /**
  3675. * Creates a new rotation matrix for "angle" radians around the Y axis
  3676. * @param angle defines the angle (in radians) to use
  3677. * @return the new matrix
  3678. */
  3679. static RotationY(angle: number): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationYToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Z axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationZ(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationZToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @return the new matrix
  3703. */
  3704. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3705. /**
  3706. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3707. * @param axis defines the axis to use
  3708. * @param angle defines the angle (in radians) to use
  3709. * @param result defines the target matrix
  3710. */
  3711. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3712. /**
  3713. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3714. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3715. * @param from defines the vector to align
  3716. * @param to defines the vector to align to
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3720. /**
  3721. * Creates a rotation matrix
  3722. * @param yaw defines the yaw angle in radians (Y axis)
  3723. * @param pitch defines the pitch angle in radians (X axis)
  3724. * @param roll defines the roll angle in radians (X axis)
  3725. * @returns the new rotation matrix
  3726. */
  3727. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3728. /**
  3729. * Creates a rotation matrix and stores it in a given matrix
  3730. * @param yaw defines the yaw angle in radians (Y axis)
  3731. * @param pitch defines the pitch angle in radians (X axis)
  3732. * @param roll defines the roll angle in radians (X axis)
  3733. * @param result defines the target matrix
  3734. */
  3735. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3736. /**
  3737. * Creates a scaling matrix
  3738. * @param x defines the scale factor on X axis
  3739. * @param y defines the scale factor on Y axis
  3740. * @param z defines the scale factor on Z axis
  3741. * @returns the new matrix
  3742. */
  3743. static Scaling(x: number, y: number, z: number): Matrix;
  3744. /**
  3745. * Creates a scaling matrix and stores it in a given matrix
  3746. * @param x defines the scale factor on X axis
  3747. * @param y defines the scale factor on Y axis
  3748. * @param z defines the scale factor on Z axis
  3749. * @param result defines the target matrix
  3750. */
  3751. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3752. /**
  3753. * Creates a translation matrix
  3754. * @param x defines the translation on X axis
  3755. * @param y defines the translation on Y axis
  3756. * @param z defines the translationon Z axis
  3757. * @returns the new matrix
  3758. */
  3759. static Translation(x: number, y: number, z: number): Matrix;
  3760. /**
  3761. * Creates a translation matrix and stores it in a given matrix
  3762. * @param x defines the translation on X axis
  3763. * @param y defines the translation on Y axis
  3764. * @param z defines the translationon Z axis
  3765. * @param result defines the target matrix
  3766. */
  3767. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3768. /**
  3769. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3770. * @param startValue defines the start value
  3771. * @param endValue defines the end value
  3772. * @param gradient defines the gradient factor
  3773. * @returns the new matrix
  3774. */
  3775. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3776. /**
  3777. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3778. * @param startValue defines the start value
  3779. * @param endValue defines the end value
  3780. * @param gradient defines the gradient factor
  3781. * @param result defines the Matrix object where to store data
  3782. */
  3783. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3784. /**
  3785. * Builds a new matrix whose values are computed by:
  3786. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3787. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3788. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3789. * @param startValue defines the first matrix
  3790. * @param endValue defines the second matrix
  3791. * @param gradient defines the gradient between the two matrices
  3792. * @returns the new matrix
  3793. */
  3794. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3795. /**
  3796. * Update a matrix to values which are computed by:
  3797. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3798. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3799. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3800. * @param startValue defines the first matrix
  3801. * @param endValue defines the second matrix
  3802. * @param gradient defines the gradient between the two matrices
  3803. * @param result defines the target matrix
  3804. */
  3805. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * 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"
  3808. * This function works in left handed mode
  3809. * @param eye defines the final position of the entity
  3810. * @param target defines where the entity should look at
  3811. * @param up defines the up vector for the entity
  3812. * @returns the new matrix
  3813. */
  3814. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3815. /**
  3816. * 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".
  3817. * This function works in left handed mode
  3818. * @param eye defines the final position of the entity
  3819. * @param target defines where the entity should look at
  3820. * @param up defines the up vector for the entity
  3821. * @param result defines the target matrix
  3822. */
  3823. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3824. /**
  3825. * 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"
  3826. * This function works in right handed mode
  3827. * @param eye defines the final position of the entity
  3828. * @param target defines where the entity should look at
  3829. * @param up defines the up vector for the entity
  3830. * @returns the new matrix
  3831. */
  3832. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3833. /**
  3834. * 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".
  3835. * This function works in right handed mode
  3836. * @param eye defines the final position of the entity
  3837. * @param target defines where the entity should look at
  3838. * @param up defines the up vector for the entity
  3839. * @param result defines the target matrix
  3840. */
  3841. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3842. /**
  3843. * Create a left-handed orthographic projection matrix
  3844. * @param width defines the viewport width
  3845. * @param height defines the viewport height
  3846. * @param znear defines the near clip plane
  3847. * @param zfar defines the far clip plane
  3848. * @returns a new matrix as a left-handed orthographic projection matrix
  3849. */
  3850. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3851. /**
  3852. * Store a left-handed orthographic projection to a given matrix
  3853. * @param width defines the viewport width
  3854. * @param height defines the viewport height
  3855. * @param znear defines the near clip plane
  3856. * @param zfar defines the far clip plane
  3857. * @param result defines the target matrix
  3858. */
  3859. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3860. /**
  3861. * Create a left-handed orthographic projection matrix
  3862. * @param left defines the viewport left coordinate
  3863. * @param right defines the viewport right coordinate
  3864. * @param bottom defines the viewport bottom coordinate
  3865. * @param top defines the viewport top coordinate
  3866. * @param znear defines the near clip plane
  3867. * @param zfar defines the far clip plane
  3868. * @returns a new matrix as a left-handed orthographic projection matrix
  3869. */
  3870. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3871. /**
  3872. * Stores a left-handed orthographic projection into a given matrix
  3873. * @param left defines the viewport left coordinate
  3874. * @param right defines the viewport right coordinate
  3875. * @param bottom defines the viewport bottom coordinate
  3876. * @param top defines the viewport top coordinate
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Creates a right-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a right-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a right-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a left-handed perspective projection matrix
  3906. * @param width defines the viewport width
  3907. * @param height defines the viewport height
  3908. * @param znear defines the near clip plane
  3909. * @param zfar defines the far clip plane
  3910. * @returns a new matrix as a left-handed perspective projection matrix
  3911. */
  3912. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3913. /**
  3914. * Creates a left-handed perspective projection matrix
  3915. * @param fov defines the horizontal field of view
  3916. * @param aspect defines the aspect ratio
  3917. * @param znear defines the near clip plane
  3918. * @param zfar defines the far clip plane
  3919. * @returns a new matrix as a left-handed perspective projection matrix
  3920. */
  3921. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3922. /**
  3923. * Stores a left-handed perspective projection into a given matrix
  3924. * @param fov defines the horizontal field of view
  3925. * @param aspect defines the aspect ratio
  3926. * @param znear defines the near clip plane
  3927. * @param zfar defines the far clip plane
  3928. * @param result defines the target matrix
  3929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3930. */
  3931. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3932. /**
  3933. * Creates a right-handed perspective projection matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @returns a new matrix as a right-handed perspective projection matrix
  3939. */
  3940. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3941. /**
  3942. * Stores a right-handed perspective projection into a given matrix
  3943. * @param fov defines the horizontal field of view
  3944. * @param aspect defines the aspect ratio
  3945. * @param znear defines the near clip plane
  3946. * @param zfar defines the far clip plane
  3947. * @param result defines the target matrix
  3948. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3949. */
  3950. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3951. /**
  3952. * Stores a perspective projection for WebVR info a given matrix
  3953. * @param fov defines the field of view
  3954. * @param znear defines the near clip plane
  3955. * @param zfar defines the far clip plane
  3956. * @param result defines the target matrix
  3957. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3958. */
  3959. static PerspectiveFovWebVRToRef(fov: {
  3960. upDegrees: number;
  3961. downDegrees: number;
  3962. leftDegrees: number;
  3963. rightDegrees: number;
  3964. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3965. /**
  3966. * Computes a complete transformation matrix
  3967. * @param viewport defines the viewport to use
  3968. * @param world defines the world matrix
  3969. * @param view defines the view matrix
  3970. * @param projection defines the projection matrix
  3971. * @param zmin defines the near clip plane
  3972. * @param zmax defines the far clip plane
  3973. * @returns the transformation matrix
  3974. */
  3975. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3976. /**
  3977. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3978. * @param matrix defines the matrix to use
  3979. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3980. */
  3981. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3982. /**
  3983. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3984. * @param matrix defines the matrix to use
  3985. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3986. */
  3987. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3988. /**
  3989. * Compute the transpose of a given matrix
  3990. * @param matrix defines the matrix to transpose
  3991. * @returns the new matrix
  3992. */
  3993. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3994. /**
  3995. * Compute the transpose of a matrix and store it in a target matrix
  3996. * @param matrix defines the matrix to transpose
  3997. * @param result defines the target matrix
  3998. */
  3999. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4000. /**
  4001. * Computes a reflection matrix from a plane
  4002. * @param plane defines the reflection plane
  4003. * @returns a new matrix
  4004. */
  4005. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4006. /**
  4007. * Computes a reflection matrix from a plane
  4008. * @param plane defines the reflection plane
  4009. * @param result defines the target matrix
  4010. */
  4011. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4012. /**
  4013. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4014. * @param xaxis defines the value of the 1st axis
  4015. * @param yaxis defines the value of the 2nd axis
  4016. * @param zaxis defines the value of the 3rd axis
  4017. * @param result defines the target matrix
  4018. */
  4019. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4020. /**
  4021. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4022. * @param quat defines the quaternion to use
  4023. * @param result defines the target matrix
  4024. */
  4025. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4026. }
  4027. /**
  4028. * @hidden
  4029. */
  4030. export class TmpVectors {
  4031. static Vector2: Vector2[];
  4032. static Vector3: Vector3[];
  4033. static Vector4: Vector4[];
  4034. static Quaternion: Quaternion[];
  4035. static Matrix: Matrix[];
  4036. }
  4037. }
  4038. declare module BABYLON {
  4039. /** Defines the cross module used constants to avoid circular dependncies */
  4040. export class Constants {
  4041. /** Defines that alpha blending is disabled */
  4042. static readonly ALPHA_DISABLE: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4044. static readonly ALPHA_ADD: number;
  4045. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4046. static readonly ALPHA_COMBINE: number;
  4047. /** Defines that alpha blending to DEST - SRC * DEST */
  4048. static readonly ALPHA_SUBTRACT: number;
  4049. /** Defines that alpha blending to SRC * DEST */
  4050. static readonly ALPHA_MULTIPLY: number;
  4051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4052. static readonly ALPHA_MAXIMIZED: number;
  4053. /** Defines that alpha blending to SRC + DEST */
  4054. static readonly ALPHA_ONEONE: number;
  4055. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_PREMULTIPLIED: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4059. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4062. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4063. static readonly ALPHA_INTERPOLATE: number;
  4064. /**
  4065. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4066. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4067. */
  4068. static readonly ALPHA_SCREENMODE: number;
  4069. /** Defines that the ressource is not delayed*/
  4070. static readonly DELAYLOADSTATE_NONE: number;
  4071. /** Defines that the ressource was successfully delay loaded */
  4072. static readonly DELAYLOADSTATE_LOADED: number;
  4073. /** Defines that the ressource is currently delay loading */
  4074. static readonly DELAYLOADSTATE_LOADING: number;
  4075. /** Defines that the ressource is delayed and has not started loading */
  4076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4078. static readonly NEVER: number;
  4079. /** 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 */
  4080. static readonly ALWAYS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4082. static readonly LESS: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4084. static readonly EQUAL: number;
  4085. /** 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 */
  4086. static readonly LEQUAL: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4088. static readonly GREATER: number;
  4089. /** 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 */
  4090. static readonly GEQUAL: number;
  4091. /** 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 */
  4092. static readonly NOTEQUAL: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be kept */
  4094. static readonly KEEP: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * 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.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */
  4465. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** @hidden */
  4470. export interface IShaderProcessor {
  4471. attributeProcessor?: (attribute: string) => string;
  4472. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4473. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4474. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4475. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4476. lineProcessor?: (line: string, isFragment: boolean) => string;
  4477. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4478. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4479. }
  4480. }
  4481. declare module BABYLON {
  4482. /** @hidden */
  4483. export interface ProcessingOptions {
  4484. defines: string[];
  4485. indexParameters: any;
  4486. isFragment: boolean;
  4487. shouldUseHighPrecisionShader: boolean;
  4488. supportsUniformBuffers: boolean;
  4489. shadersRepository: string;
  4490. includesShadersStore: {
  4491. [key: string]: string;
  4492. };
  4493. processor?: IShaderProcessor;
  4494. version: string;
  4495. platformName: string;
  4496. lookForClosingBracketForUniformBuffer?: boolean;
  4497. }
  4498. }
  4499. declare module BABYLON {
  4500. /**
  4501. * Helper to manipulate strings
  4502. */
  4503. export class StringTools {
  4504. /**
  4505. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4506. * @param str Source string
  4507. * @param suffix Suffix to search for in the source string
  4508. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4509. */
  4510. static EndsWith(str: string, suffix: string): boolean;
  4511. /**
  4512. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4513. * @param str Source string
  4514. * @param suffix Suffix to search for in the source string
  4515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4516. */
  4517. static StartsWith(str: string, suffix: string): boolean;
  4518. }
  4519. }
  4520. declare module BABYLON {
  4521. /** @hidden */
  4522. export class ShaderCodeNode {
  4523. line: string;
  4524. children: ShaderCodeNode[];
  4525. additionalDefineKey?: string;
  4526. additionalDefineValue?: string;
  4527. isValid(preprocessors: {
  4528. [key: string]: string;
  4529. }): boolean;
  4530. process(preprocessors: {
  4531. [key: string]: string;
  4532. }, options: ProcessingOptions): string;
  4533. }
  4534. }
  4535. declare module BABYLON {
  4536. /** @hidden */
  4537. export class ShaderCodeCursor {
  4538. private _lines;
  4539. lineIndex: number;
  4540. readonly currentLine: string;
  4541. readonly canRead: boolean;
  4542. lines: string[];
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4548. process(preprocessors: {
  4549. [key: string]: string;
  4550. }, options: ProcessingOptions): string;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderDefineExpression {
  4556. isTrue(preprocessors: {
  4557. [key: string]: string;
  4558. }): boolean;
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /** @hidden */
  4563. export class ShaderCodeTestNode extends ShaderCodeNode {
  4564. testExpression: ShaderDefineExpression;
  4565. isValid(preprocessors: {
  4566. [key: string]: string;
  4567. }): boolean;
  4568. }
  4569. }
  4570. declare module BABYLON {
  4571. /** @hidden */
  4572. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4573. define: string;
  4574. not: boolean;
  4575. constructor(define: string, not?: boolean);
  4576. isTrue(preprocessors: {
  4577. [key: string]: string;
  4578. }): boolean;
  4579. }
  4580. }
  4581. declare module BABYLON {
  4582. /** @hidden */
  4583. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4584. leftOperand: ShaderDefineExpression;
  4585. rightOperand: ShaderDefineExpression;
  4586. isTrue(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module BABYLON {
  4592. /** @hidden */
  4593. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4594. leftOperand: ShaderDefineExpression;
  4595. rightOperand: ShaderDefineExpression;
  4596. isTrue(preprocessors: {
  4597. [key: string]: string;
  4598. }): boolean;
  4599. }
  4600. }
  4601. declare module BABYLON {
  4602. /** @hidden */
  4603. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4604. define: string;
  4605. operand: string;
  4606. testValue: string;
  4607. constructor(define: string, operand: string, testValue: string);
  4608. isTrue(preprocessors: {
  4609. [key: string]: string;
  4610. }): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * @ignore
  4616. * Application error to support additional information when loading a file
  4617. */
  4618. export class LoadFileError extends Error {
  4619. /** defines the optional web request */
  4620. request?: WebRequest | undefined;
  4621. private static _setPrototypeOf;
  4622. /**
  4623. * Creates a new LoadFileError
  4624. * @param message defines the message of the error
  4625. * @param request defines the optional web request
  4626. */
  4627. constructor(message: string,
  4628. /** defines the optional web request */
  4629. request?: WebRequest | undefined);
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to enable access to offline support
  4635. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4636. */
  4637. export interface IOfflineProvider {
  4638. /**
  4639. * Gets a boolean indicating if scene must be saved in the database
  4640. */
  4641. enableSceneOffline: boolean;
  4642. /**
  4643. * Gets a boolean indicating if textures must be saved in the database
  4644. */
  4645. enableTexturesOffline: boolean;
  4646. /**
  4647. * Open the offline support and make it available
  4648. * @param successCallback defines the callback to call on success
  4649. * @param errorCallback defines the callback to call on error
  4650. */
  4651. open(successCallback: () => void, errorCallback: () => void): void;
  4652. /**
  4653. * Loads an image from the offline support
  4654. * @param url defines the url to load from
  4655. * @param image defines the target DOM image
  4656. */
  4657. loadImage(url: string, image: HTMLImageElement): void;
  4658. /**
  4659. * Loads a file from offline support
  4660. * @param url defines the URL to load from
  4661. * @param sceneLoaded defines a callback to call on success
  4662. * @param progressCallBack defines a callback to call when progress changed
  4663. * @param errorCallback defines a callback to call on error
  4664. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4665. */
  4666. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4667. }
  4668. }
  4669. declare module BABYLON {
  4670. /**
  4671. * Class used to help managing file picking and drag'n'drop
  4672. * File Storage
  4673. */
  4674. export class FilesInputStore {
  4675. /**
  4676. * List of files ready to be loaded
  4677. */
  4678. static FilesToLoad: {
  4679. [key: string]: File;
  4680. };
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to define a retry strategy when error happens while loading assets
  4686. */
  4687. export class RetryStrategy {
  4688. /**
  4689. * Function used to defines an exponential back off strategy
  4690. * @param maxRetries defines the maximum number of retries (3 by default)
  4691. * @param baseInterval defines the interval between retries
  4692. * @returns the strategy function to use
  4693. */
  4694. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. /**
  4699. * @hidden
  4700. */
  4701. export class FileTools {
  4702. /**
  4703. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4704. */
  4705. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4706. /**
  4707. * Gets or sets the base URL to use to load assets
  4708. */
  4709. static BaseUrl: string;
  4710. /**
  4711. * Default behaviour for cors in the application.
  4712. * It can be a string if the expected behavior is identical in the entire app.
  4713. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4714. */
  4715. static CorsBehavior: string | ((url: string | string[]) => string);
  4716. /**
  4717. * Gets or sets a function used to pre-process url before using them to load assets
  4718. */
  4719. static PreprocessUrl: (url: string) => string;
  4720. /**
  4721. * Removes unwanted characters from an url
  4722. * @param url defines the url to clean
  4723. * @returns the cleaned url
  4724. */
  4725. private static _CleanUrl;
  4726. /**
  4727. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4728. * @param url define the url we are trying
  4729. * @param element define the dom element where to configure the cors policy
  4730. */
  4731. static SetCorsBehavior(url: string | string[], element: {
  4732. crossOrigin: string | null;
  4733. }): void;
  4734. /**
  4735. * Loads an image as an HTMLImageElement.
  4736. * @param input url string, ArrayBuffer, or Blob to load
  4737. * @param onLoad callback called when the image successfully loads
  4738. * @param onError callback called when the image fails to load
  4739. * @param offlineProvider offline provider for caching
  4740. * @returns the HTMLImageElement of the loaded image
  4741. */
  4742. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4743. /**
  4744. * Loads a file
  4745. * @param fileToLoad defines the file to load
  4746. * @param callback defines the callback to call when data is loaded
  4747. * @param progressCallBack defines the callback to call during loading process
  4748. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4749. * @returns a file request object
  4750. */
  4751. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4752. /**
  4753. * Loads a file
  4754. * @param url url string, ArrayBuffer, or Blob to load
  4755. * @param onSuccess callback called when the file successfully loads
  4756. * @param onProgress callback called while file is loading (if the server supports this mode)
  4757. * @param offlineProvider defines the offline provider for caching
  4758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4759. * @param onError callback called when the file fails to load
  4760. * @returns a file request object
  4761. */
  4762. 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;
  4763. /**
  4764. * Checks if the loaded document was accessed via `file:`-Protocol.
  4765. * @returns boolean
  4766. */
  4767. static IsFileURL(): boolean;
  4768. }
  4769. }
  4770. declare module BABYLON {
  4771. /** @hidden */
  4772. export class ShaderProcessor {
  4773. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4774. private static _ProcessPrecision;
  4775. private static _ExtractOperation;
  4776. private static _BuildSubExpression;
  4777. private static _BuildExpression;
  4778. private static _MoveCursorWithinIf;
  4779. private static _MoveCursor;
  4780. private static _EvaluatePreProcessors;
  4781. private static _PreparePreProcessors;
  4782. private static _ProcessShaderConversion;
  4783. private static _ProcessIncludes;
  4784. }
  4785. }
  4786. declare module BABYLON {
  4787. /**
  4788. * Class used to hold a RBG color
  4789. */
  4790. export class Color3 {
  4791. /**
  4792. * Defines the red component (between 0 and 1, default is 0)
  4793. */
  4794. r: number;
  4795. /**
  4796. * Defines the green component (between 0 and 1, default is 0)
  4797. */
  4798. g: number;
  4799. /**
  4800. * Defines the blue component (between 0 and 1, default is 0)
  4801. */
  4802. b: number;
  4803. /**
  4804. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4805. * @param r defines the red component (between 0 and 1, default is 0)
  4806. * @param g defines the green component (between 0 and 1, default is 0)
  4807. * @param b defines the blue component (between 0 and 1, default is 0)
  4808. */
  4809. constructor(
  4810. /**
  4811. * Defines the red component (between 0 and 1, default is 0)
  4812. */
  4813. r?: number,
  4814. /**
  4815. * Defines the green component (between 0 and 1, default is 0)
  4816. */
  4817. g?: number,
  4818. /**
  4819. * Defines the blue component (between 0 and 1, default is 0)
  4820. */
  4821. b?: number);
  4822. /**
  4823. * Creates a string with the Color3 current values
  4824. * @returns the string representation of the Color3 object
  4825. */
  4826. toString(): string;
  4827. /**
  4828. * Returns the string "Color3"
  4829. * @returns "Color3"
  4830. */
  4831. getClassName(): string;
  4832. /**
  4833. * Compute the Color3 hash code
  4834. * @returns an unique number that can be used to hash Color3 objects
  4835. */
  4836. getHashCode(): number;
  4837. /**
  4838. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4839. * @param array defines the array where to store the r,g,b components
  4840. * @param index defines an optional index in the target array to define where to start storing values
  4841. * @returns the current Color3 object
  4842. */
  4843. toArray(array: FloatArray, index?: number): Color3;
  4844. /**
  4845. * Returns a new Color4 object from the current Color3 and the given alpha
  4846. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4847. * @returns a new Color4 object
  4848. */
  4849. toColor4(alpha?: number): Color4;
  4850. /**
  4851. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4852. * @returns the new array
  4853. */
  4854. asArray(): number[];
  4855. /**
  4856. * Returns the luminance value
  4857. * @returns a float value
  4858. */
  4859. toLuminance(): number;
  4860. /**
  4861. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4862. * @param otherColor defines the second operand
  4863. * @returns the new Color3 object
  4864. */
  4865. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4866. /**
  4867. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4868. * @param otherColor defines the second operand
  4869. * @param result defines the Color3 object where to store the result
  4870. * @returns the current Color3
  4871. */
  4872. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4873. /**
  4874. * Determines equality between Color3 objects
  4875. * @param otherColor defines the second operand
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equals(otherColor: DeepImmutable<Color3>): boolean;
  4879. /**
  4880. * Determines equality between the current Color3 object and a set of r,b,g values
  4881. * @param r defines the red component to check
  4882. * @param g defines the green component to check
  4883. * @param b defines the blue component to check
  4884. * @returns true if the rgb values are equal to the given ones
  4885. */
  4886. equalsFloats(r: number, g: number, b: number): boolean;
  4887. /**
  4888. * Multiplies in place each rgb value by scale
  4889. * @param scale defines the scaling factor
  4890. * @returns the updated Color3
  4891. */
  4892. scale(scale: number): Color3;
  4893. /**
  4894. * Multiplies the rgb values by scale and stores the result into "result"
  4895. * @param scale defines the scaling factor
  4896. * @param result defines the Color3 object where to store the result
  4897. * @returns the unmodified current Color3
  4898. */
  4899. scaleToRef(scale: number, result: Color3): Color3;
  4900. /**
  4901. * Scale the current Color3 values by a factor and add the result to a given Color3
  4902. * @param scale defines the scale factor
  4903. * @param result defines color to store the result into
  4904. * @returns the unmodified current Color3
  4905. */
  4906. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4907. /**
  4908. * Clamps the rgb values by the min and max values and stores the result into "result"
  4909. * @param min defines minimum clamping value (default is 0)
  4910. * @param max defines maximum clamping value (default is 1)
  4911. * @param result defines color to store the result into
  4912. * @returns the original Color3
  4913. */
  4914. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4915. /**
  4916. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4917. * @param otherColor defines the second operand
  4918. * @returns the new Color3
  4919. */
  4920. add(otherColor: DeepImmutable<Color3>): Color3;
  4921. /**
  4922. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4923. * @param otherColor defines the second operand
  4924. * @param result defines Color3 object to store the result into
  4925. * @returns the unmodified current Color3
  4926. */
  4927. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4928. /**
  4929. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4930. * @param otherColor defines the second operand
  4931. * @returns the new Color3
  4932. */
  4933. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4934. /**
  4935. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4936. * @param otherColor defines the second operand
  4937. * @param result defines Color3 object to store the result into
  4938. * @returns the unmodified current Color3
  4939. */
  4940. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4941. /**
  4942. * Copy the current object
  4943. * @returns a new Color3 copied the current one
  4944. */
  4945. clone(): Color3;
  4946. /**
  4947. * Copies the rgb values from the source in the current Color3
  4948. * @param source defines the source Color3 object
  4949. * @returns the updated Color3 object
  4950. */
  4951. copyFrom(source: DeepImmutable<Color3>): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. copyFromFloats(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Updates the Color3 rgb values from the given floats
  4962. * @param r defines the red component to read from
  4963. * @param g defines the green component to read from
  4964. * @param b defines the blue component to read from
  4965. * @returns the current Color3 object
  4966. */
  4967. set(r: number, g: number, b: number): Color3;
  4968. /**
  4969. * Compute the Color3 hexadecimal code as a string
  4970. * @returns a string containing the hexadecimal representation of the Color3 object
  4971. */
  4972. toHexString(): string;
  4973. /**
  4974. * Computes a new Color3 converted from the current one to linear space
  4975. * @returns a new Color3 object
  4976. */
  4977. toLinearSpace(): Color3;
  4978. /**
  4979. * Converts current color in rgb space to HSV values
  4980. * @returns a new color3 representing the HSV values
  4981. */
  4982. toHSV(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @param result defines the Color3 where to store the HSV values
  4986. */
  4987. toHSVToRef(result: Color3): void;
  4988. /**
  4989. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4990. * @param convertedColor defines the Color3 object where to store the linear space version
  4991. * @returns the unmodified Color3
  4992. */
  4993. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4994. /**
  4995. * Computes a new Color3 converted from the current one to gamma space
  4996. * @returns a new Color3 object
  4997. */
  4998. toGammaSpace(): Color3;
  4999. /**
  5000. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5001. * @param convertedColor defines the Color3 object where to store the gamma space version
  5002. * @returns the unmodified Color3
  5003. */
  5004. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5005. private static _BlackReadOnly;
  5006. /**
  5007. * Convert Hue, saturation and value to a Color3 (RGB)
  5008. * @param hue defines the hue
  5009. * @param saturation defines the saturation
  5010. * @param value defines the value
  5011. * @param result defines the Color3 where to store the RGB values
  5012. */
  5013. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5014. /**
  5015. * Creates a new Color3 from the string containing valid hexadecimal values
  5016. * @param hex defines a string containing valid hexadecimal values
  5017. * @returns a new Color3 object
  5018. */
  5019. static FromHexString(hex: string): Color3;
  5020. /**
  5021. * Creates a new Color3 from the starting index of the given array
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5027. /**
  5028. * Creates a new Color3 from integer values (< 256)
  5029. * @param r defines the red component to read from (value between 0 and 255)
  5030. * @param g defines the green component to read from (value between 0 and 255)
  5031. * @param b defines the blue component to read from (value between 0 and 255)
  5032. * @returns a new Color3 object
  5033. */
  5034. static FromInts(r: number, g: number, b: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param start defines the start Color3 value
  5038. * @param end defines the end Color3 value
  5039. * @param amount defines the gradient value between start and end
  5040. * @returns a new Color3 object
  5041. */
  5042. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5043. /**
  5044. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5045. * @param left defines the start value
  5046. * @param right defines the end value
  5047. * @param amount defines the gradient factor
  5048. * @param result defines the Color3 object where to store the result
  5049. */
  5050. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5051. /**
  5052. * Returns a Color3 value containing a red color
  5053. * @returns a new Color3 object
  5054. */
  5055. static Red(): Color3;
  5056. /**
  5057. * Returns a Color3 value containing a green color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Green(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a blue color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Blue(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a black color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Black(): Color3;
  5071. /**
  5072. * Gets a Color3 value containing a black color that must not be updated
  5073. */
  5074. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5075. /**
  5076. * Returns a Color3 value containing a white color
  5077. * @returns a new Color3 object
  5078. */
  5079. static White(): Color3;
  5080. /**
  5081. * Returns a Color3 value containing a purple color
  5082. * @returns a new Color3 object
  5083. */
  5084. static Purple(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a magenta color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Magenta(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a yellow color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Yellow(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a gray color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Gray(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a teal color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Teal(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a random color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Random(): Color3;
  5110. }
  5111. /**
  5112. * Class used to hold a RBGA color
  5113. */
  5114. export class Color4 {
  5115. /**
  5116. * Defines the red component (between 0 and 1, default is 0)
  5117. */
  5118. r: number;
  5119. /**
  5120. * Defines the green component (between 0 and 1, default is 0)
  5121. */
  5122. g: number;
  5123. /**
  5124. * Defines the blue component (between 0 and 1, default is 0)
  5125. */
  5126. b: number;
  5127. /**
  5128. * Defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. a: number;
  5131. /**
  5132. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5133. * @param r defines the red component (between 0 and 1, default is 0)
  5134. * @param g defines the green component (between 0 and 1, default is 0)
  5135. * @param b defines the blue component (between 0 and 1, default is 0)
  5136. * @param a defines the alpha component (between 0 and 1, default is 1)
  5137. */
  5138. constructor(
  5139. /**
  5140. * Defines the red component (between 0 and 1, default is 0)
  5141. */
  5142. r?: number,
  5143. /**
  5144. * Defines the green component (between 0 and 1, default is 0)
  5145. */
  5146. g?: number,
  5147. /**
  5148. * Defines the blue component (between 0 and 1, default is 0)
  5149. */
  5150. b?: number,
  5151. /**
  5152. * Defines the alpha component (between 0 and 1, default is 1)
  5153. */
  5154. a?: number);
  5155. /**
  5156. * Adds in place the given Color4 values to the current Color4 object
  5157. * @param right defines the second operand
  5158. * @returns the current updated Color4 object
  5159. */
  5160. addInPlace(right: DeepImmutable<Color4>): Color4;
  5161. /**
  5162. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5163. * @returns the new array
  5164. */
  5165. asArray(): number[];
  5166. /**
  5167. * Stores from the starting index in the given array the Color4 successive values
  5168. * @param array defines the array where to store the r,g,b components
  5169. * @param index defines an optional index in the target array to define where to start storing values
  5170. * @returns the current Color4 object
  5171. */
  5172. toArray(array: number[], index?: number): Color4;
  5173. /**
  5174. * Determines equality between Color4 objects
  5175. * @param otherColor defines the second operand
  5176. * @returns true if the rgba values are equal to the given ones
  5177. */
  5178. equals(otherColor: DeepImmutable<Color4>): boolean;
  5179. /**
  5180. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5181. * @param right defines the second operand
  5182. * @returns a new Color4 object
  5183. */
  5184. add(right: DeepImmutable<Color4>): Color4;
  5185. /**
  5186. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5187. * @param right defines the second operand
  5188. * @returns a new Color4 object
  5189. */
  5190. subtract(right: DeepImmutable<Color4>): Color4;
  5191. /**
  5192. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5193. * @param right defines the second operand
  5194. * @param result defines the Color4 object where to store the result
  5195. * @returns the current Color4 object
  5196. */
  5197. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5198. /**
  5199. * Creates a new Color4 with the current Color4 values multiplied by scale
  5200. * @param scale defines the scaling factor to apply
  5201. * @returns a new Color4 object
  5202. */
  5203. scale(scale: number): Color4;
  5204. /**
  5205. * Multiplies the current Color4 values by scale and stores the result in "result"
  5206. * @param scale defines the scaling factor to apply
  5207. * @param result defines the Color4 object where to store the result
  5208. * @returns the current unmodified Color4
  5209. */
  5210. scaleToRef(scale: number, result: Color4): Color4;
  5211. /**
  5212. * Scale the current Color4 values by a factor and add the result to a given Color4
  5213. * @param scale defines the scale factor
  5214. * @param result defines the Color4 object where to store the result
  5215. * @returns the unmodified current Color4
  5216. */
  5217. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5218. /**
  5219. * Clamps the rgb values by the min and max values and stores the result into "result"
  5220. * @param min defines minimum clamping value (default is 0)
  5221. * @param max defines maximum clamping value (default is 1)
  5222. * @param result defines color to store the result into.
  5223. * @returns the cuurent Color4
  5224. */
  5225. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5226. /**
  5227. * Multipy an Color4 value by another and return a new Color4 object
  5228. * @param color defines the Color4 value to multiply by
  5229. * @returns a new Color4 object
  5230. */
  5231. multiply(color: Color4): Color4;
  5232. /**
  5233. * Multipy a Color4 value by another and push the result in a reference value
  5234. * @param color defines the Color4 value to multiply by
  5235. * @param result defines the Color4 to fill the result in
  5236. * @returns the result Color4
  5237. */
  5238. multiplyToRef(color: Color4, result: Color4): Color4;
  5239. /**
  5240. * Creates a string with the Color4 current values
  5241. * @returns the string representation of the Color4 object
  5242. */
  5243. toString(): string;
  5244. /**
  5245. * Returns the string "Color4"
  5246. * @returns "Color4"
  5247. */
  5248. getClassName(): string;
  5249. /**
  5250. * Compute the Color4 hash code
  5251. * @returns an unique number that can be used to hash Color4 objects
  5252. */
  5253. getHashCode(): number;
  5254. /**
  5255. * Creates a new Color4 copied from the current one
  5256. * @returns a new Color4 object
  5257. */
  5258. clone(): Color4;
  5259. /**
  5260. * Copies the given Color4 values into the current one
  5261. * @param source defines the source Color4 object
  5262. * @returns the current updated Color4 object
  5263. */
  5264. copyFrom(source: Color4): Color4;
  5265. /**
  5266. * Copies the given float values into the current one
  5267. * @param r defines the red component to read from
  5268. * @param g defines the green component to read from
  5269. * @param b defines the blue component to read from
  5270. * @param a defines the alpha component to read from
  5271. * @returns the current updated Color4 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5274. /**
  5275. * Copies the given float values into the current one
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @param a defines the alpha component to read from
  5280. * @returns the current updated Color4 object
  5281. */
  5282. set(r: number, g: number, b: number, a: number): Color4;
  5283. /**
  5284. * Compute the Color4 hexadecimal code as a string
  5285. * @returns a string containing the hexadecimal representation of the Color4 object
  5286. */
  5287. toHexString(): string;
  5288. /**
  5289. * Computes a new Color4 converted from the current one to linear space
  5290. * @returns a new Color4 object
  5291. */
  5292. toLinearSpace(): Color4;
  5293. /**
  5294. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5295. * @param convertedColor defines the Color4 object where to store the linear space version
  5296. * @returns the unmodified Color4
  5297. */
  5298. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5299. /**
  5300. * Computes a new Color4 converted from the current one to gamma space
  5301. * @returns a new Color4 object
  5302. */
  5303. toGammaSpace(): Color4;
  5304. /**
  5305. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color4 object where to store the gamma space version
  5307. * @returns the unmodified Color4
  5308. */
  5309. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5310. /**
  5311. * Creates a new Color4 from the string containing valid hexadecimal values
  5312. * @param hex defines a string containing valid hexadecimal values
  5313. * @returns a new Color4 object
  5314. */
  5315. static FromHexString(hex: string): Color4;
  5316. /**
  5317. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @returns a new Color4 object
  5322. */
  5323. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5324. /**
  5325. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5326. * @param left defines the start value
  5327. * @param right defines the end value
  5328. * @param amount defines the gradient factor
  5329. * @param result defines the Color4 object where to store data
  5330. */
  5331. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5332. /**
  5333. * Creates a new Color4 from a Color3 and an alpha value
  5334. * @param color3 defines the source Color3 to read from
  5335. * @param alpha defines the alpha component (1.0 by default)
  5336. * @returns a new Color4 object
  5337. */
  5338. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5339. /**
  5340. * Creates a new Color4 from the starting index element of the given array
  5341. * @param array defines the source array to read from
  5342. * @param offset defines the offset in the source array
  5343. * @returns a new Color4 object
  5344. */
  5345. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5346. /**
  5347. * Creates a new Color3 from integer values (< 256)
  5348. * @param r defines the red component to read from (value between 0 and 255)
  5349. * @param g defines the green component to read from (value between 0 and 255)
  5350. * @param b defines the blue component to read from (value between 0 and 255)
  5351. * @param a defines the alpha component to read from (value between 0 and 255)
  5352. * @returns a new Color3 object
  5353. */
  5354. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5355. /**
  5356. * Check the content of a given array and convert it to an array containing RGBA data
  5357. * If the original array was already containing count * 4 values then it is returned directly
  5358. * @param colors defines the array to check
  5359. * @param count defines the number of RGBA data to expect
  5360. * @returns an array containing count * 4 values (RGBA)
  5361. */
  5362. static CheckColors4(colors: number[], count: number): number[];
  5363. }
  5364. /**
  5365. * @hidden
  5366. */
  5367. export class TmpColors {
  5368. static Color3: Color3[];
  5369. static Color4: Color4[];
  5370. }
  5371. }
  5372. declare module BABYLON {
  5373. /**
  5374. * Class representing spherical harmonics coefficients to the 3rd degree
  5375. */
  5376. export class SphericalHarmonics {
  5377. /**
  5378. * Defines whether or not the harmonics have been prescaled for rendering.
  5379. */
  5380. preScaled: boolean;
  5381. /**
  5382. * The l0,0 coefficients of the spherical harmonics
  5383. */
  5384. l00: Vector3;
  5385. /**
  5386. * The l1,-1 coefficients of the spherical harmonics
  5387. */
  5388. l1_1: Vector3;
  5389. /**
  5390. * The l1,0 coefficients of the spherical harmonics
  5391. */
  5392. l10: Vector3;
  5393. /**
  5394. * The l1,1 coefficients of the spherical harmonics
  5395. */
  5396. l11: Vector3;
  5397. /**
  5398. * The l2,-2 coefficients of the spherical harmonics
  5399. */
  5400. l2_2: Vector3;
  5401. /**
  5402. * The l2,-1 coefficients of the spherical harmonics
  5403. */
  5404. l2_1: Vector3;
  5405. /**
  5406. * The l2,0 coefficients of the spherical harmonics
  5407. */
  5408. l20: Vector3;
  5409. /**
  5410. * The l2,1 coefficients of the spherical harmonics
  5411. */
  5412. l21: Vector3;
  5413. /**
  5414. * The l2,2 coefficients of the spherical harmonics
  5415. */
  5416. l22: Vector3;
  5417. /**
  5418. * Adds a light to the spherical harmonics
  5419. * @param direction the direction of the light
  5420. * @param color the color of the light
  5421. * @param deltaSolidAngle the delta solid angle of the light
  5422. */
  5423. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5424. /**
  5425. * Scales the spherical harmonics by the given amount
  5426. * @param scale the amount to scale
  5427. */
  5428. scaleInPlace(scale: number): void;
  5429. /**
  5430. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5431. *
  5432. * ```
  5433. * E_lm = A_l * L_lm
  5434. * ```
  5435. *
  5436. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5437. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5438. * the scaling factors are given in equation 9.
  5439. */
  5440. convertIncidentRadianceToIrradiance(): void;
  5441. /**
  5442. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5443. *
  5444. * ```
  5445. * L = (1/pi) * E * rho
  5446. * ```
  5447. *
  5448. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5449. */
  5450. convertIrradianceToLambertianRadiance(): void;
  5451. /**
  5452. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5453. * required operations at run time.
  5454. *
  5455. * This is simply done by scaling back the SH with Ylm constants parameter.
  5456. * The trigonometric part being applied by the shader at run time.
  5457. */
  5458. preScaleForRendering(): void;
  5459. /**
  5460. * Constructs a spherical harmonics from an array.
  5461. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5462. * @returns the spherical harmonics
  5463. */
  5464. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5465. /**
  5466. * Gets the spherical harmonics from polynomial
  5467. * @param polynomial the spherical polynomial
  5468. * @returns the spherical harmonics
  5469. */
  5470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5471. }
  5472. /**
  5473. * Class representing spherical polynomial coefficients to the 3rd degree
  5474. */
  5475. export class SphericalPolynomial {
  5476. private _harmonics;
  5477. /**
  5478. * The spherical harmonics used to create the polynomials.
  5479. */
  5480. readonly preScaledHarmonics: SphericalHarmonics;
  5481. /**
  5482. * The x coefficients of the spherical polynomial
  5483. */
  5484. x: Vector3;
  5485. /**
  5486. * The y coefficients of the spherical polynomial
  5487. */
  5488. y: Vector3;
  5489. /**
  5490. * The z coefficients of the spherical polynomial
  5491. */
  5492. z: Vector3;
  5493. /**
  5494. * The xx coefficients of the spherical polynomial
  5495. */
  5496. xx: Vector3;
  5497. /**
  5498. * The yy coefficients of the spherical polynomial
  5499. */
  5500. yy: Vector3;
  5501. /**
  5502. * The zz coefficients of the spherical polynomial
  5503. */
  5504. zz: Vector3;
  5505. /**
  5506. * The xy coefficients of the spherical polynomial
  5507. */
  5508. xy: Vector3;
  5509. /**
  5510. * The yz coefficients of the spherical polynomial
  5511. */
  5512. yz: Vector3;
  5513. /**
  5514. * The zx coefficients of the spherical polynomial
  5515. */
  5516. zx: Vector3;
  5517. /**
  5518. * Adds an ambient color to the spherical polynomial
  5519. * @param color the color to add
  5520. */
  5521. addAmbient(color: Color3): void;
  5522. /**
  5523. * Scales the spherical polynomial by the given amount
  5524. * @param scale the amount to scale
  5525. */
  5526. scaleInPlace(scale: number): void;
  5527. /**
  5528. * Gets the spherical polynomial from harmonics
  5529. * @param harmonics the spherical harmonics
  5530. * @returns the spherical polynomial
  5531. */
  5532. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5533. /**
  5534. * Constructs a spherical polynomial from an array.
  5535. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5536. * @returns the spherical polynomial
  5537. */
  5538. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. /**
  5543. * Define options used to create a render target texture
  5544. */
  5545. export class RenderTargetCreationOptions {
  5546. /**
  5547. * Specifies is mipmaps must be generated
  5548. */
  5549. generateMipMaps?: boolean;
  5550. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5551. generateDepthBuffer?: boolean;
  5552. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5553. generateStencilBuffer?: boolean;
  5554. /** Defines texture type (int by default) */
  5555. type?: number;
  5556. /** Defines sampling mode (trilinear by default) */
  5557. samplingMode?: number;
  5558. /** Defines format (RGBA by default) */
  5559. format?: number;
  5560. }
  5561. }
  5562. declare module BABYLON {
  5563. /**
  5564. * @hidden
  5565. **/
  5566. export class _AlphaState {
  5567. private _isAlphaBlendDirty;
  5568. private _isBlendFunctionParametersDirty;
  5569. private _isBlendEquationParametersDirty;
  5570. private _isBlendConstantsDirty;
  5571. private _alphaBlend;
  5572. private _blendFunctionParameters;
  5573. private _blendEquationParameters;
  5574. private _blendConstants;
  5575. /**
  5576. * Initializes the state.
  5577. */
  5578. constructor();
  5579. readonly isDirty: boolean;
  5580. alphaBlend: boolean;
  5581. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5582. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5583. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5584. reset(): void;
  5585. apply(gl: WebGLRenderingContext): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. /**
  5590. * @hidden
  5591. **/
  5592. export class _DepthCullingState {
  5593. private _isDepthTestDirty;
  5594. private _isDepthMaskDirty;
  5595. private _isDepthFuncDirty;
  5596. private _isCullFaceDirty;
  5597. private _isCullDirty;
  5598. private _isZOffsetDirty;
  5599. private _isFrontFaceDirty;
  5600. private _depthTest;
  5601. private _depthMask;
  5602. private _depthFunc;
  5603. private _cull;
  5604. private _cullFace;
  5605. private _zOffset;
  5606. private _frontFace;
  5607. /**
  5608. * Initializes the state.
  5609. */
  5610. constructor();
  5611. readonly isDirty: boolean;
  5612. zOffset: number;
  5613. cullFace: Nullable<number>;
  5614. cull: Nullable<boolean>;
  5615. depthFunc: Nullable<number>;
  5616. depthMask: boolean;
  5617. depthTest: boolean;
  5618. frontFace: Nullable<number>;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module BABYLON {
  5624. /**
  5625. * @hidden
  5626. **/
  5627. export class _StencilState {
  5628. /** 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 */
  5629. static readonly ALWAYS: number;
  5630. /** Passed to stencilOperation to specify that stencil value must be kept */
  5631. static readonly KEEP: number;
  5632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5633. static readonly REPLACE: number;
  5634. private _isStencilTestDirty;
  5635. private _isStencilMaskDirty;
  5636. private _isStencilFuncDirty;
  5637. private _isStencilOpDirty;
  5638. private _stencilTest;
  5639. private _stencilMask;
  5640. private _stencilFunc;
  5641. private _stencilFuncRef;
  5642. private _stencilFuncMask;
  5643. private _stencilOpStencilFail;
  5644. private _stencilOpDepthFail;
  5645. private _stencilOpStencilDepthPass;
  5646. readonly isDirty: boolean;
  5647. stencilFunc: number;
  5648. stencilFuncRef: number;
  5649. stencilFuncMask: number;
  5650. stencilOpStencilFail: number;
  5651. stencilOpDepthFail: number;
  5652. stencilOpStencilDepthPass: number;
  5653. stencilMask: number;
  5654. stencilTest: boolean;
  5655. constructor();
  5656. reset(): void;
  5657. apply(gl: WebGLRenderingContext): void;
  5658. }
  5659. }
  5660. declare module BABYLON {
  5661. /**
  5662. * @hidden
  5663. **/
  5664. export class _TimeToken {
  5665. _startTimeQuery: Nullable<WebGLQuery>;
  5666. _endTimeQuery: Nullable<WebGLQuery>;
  5667. _timeElapsedQuery: Nullable<WebGLQuery>;
  5668. _timeElapsedQueryEnded: boolean;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class used to evalaute queries containing `and` and `or` operators
  5674. */
  5675. export class AndOrNotEvaluator {
  5676. /**
  5677. * Evaluate a query
  5678. * @param query defines the query to evaluate
  5679. * @param evaluateCallback defines the callback used to filter result
  5680. * @returns true if the query matches
  5681. */
  5682. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5683. private static _HandleParenthesisContent;
  5684. private static _SimplifyNegation;
  5685. }
  5686. }
  5687. declare module BABYLON {
  5688. /**
  5689. * Class used to store custom tags
  5690. */
  5691. export class Tags {
  5692. /**
  5693. * Adds support for tags on the given object
  5694. * @param obj defines the object to use
  5695. */
  5696. static EnableFor(obj: any): void;
  5697. /**
  5698. * Removes tags support
  5699. * @param obj defines the object to use
  5700. */
  5701. static DisableFor(obj: any): void;
  5702. /**
  5703. * Gets a boolean indicating if the given object has tags
  5704. * @param obj defines the object to use
  5705. * @returns a boolean
  5706. */
  5707. static HasTags(obj: any): boolean;
  5708. /**
  5709. * Gets the tags available on a given object
  5710. * @param obj defines the object to use
  5711. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5712. * @returns the tags
  5713. */
  5714. static GetTags(obj: any, asString?: boolean): any;
  5715. /**
  5716. * Adds tags to an object
  5717. * @param obj defines the object to use
  5718. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5719. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5720. */
  5721. static AddTagsTo(obj: any, tagsString: string): void;
  5722. /**
  5723. * @hidden
  5724. */
  5725. static _AddTagTo(obj: any, tag: string): void;
  5726. /**
  5727. * Removes specific tags from a specific object
  5728. * @param obj defines the object to use
  5729. * @param tagsString defines the tags to remove
  5730. */
  5731. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5732. /**
  5733. * @hidden
  5734. */
  5735. static _RemoveTagFrom(obj: any, tag: string): void;
  5736. /**
  5737. * Defines if tags hosted on an object match a given query
  5738. * @param obj defines the object to use
  5739. * @param tagsQuery defines the tag query
  5740. * @returns a boolean
  5741. */
  5742. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Defines potential orientation for back face culling
  5748. */
  5749. export enum Orientation {
  5750. /**
  5751. * Clockwise
  5752. */
  5753. CW = 0,
  5754. /** Counter clockwise */
  5755. CCW = 1
  5756. }
  5757. /** Class used to represent a Bezier curve */
  5758. export class BezierCurve {
  5759. /**
  5760. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5761. * @param t defines the time
  5762. * @param x1 defines the left coordinate on X axis
  5763. * @param y1 defines the left coordinate on Y axis
  5764. * @param x2 defines the right coordinate on X axis
  5765. * @param y2 defines the right coordinate on Y axis
  5766. * @returns the interpolated value
  5767. */
  5768. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5769. }
  5770. /**
  5771. * Defines angle representation
  5772. */
  5773. export class Angle {
  5774. private _radians;
  5775. /**
  5776. * Creates an Angle object of "radians" radians (float).
  5777. * @param radians the angle in radians
  5778. */
  5779. constructor(radians: number);
  5780. /**
  5781. * Get value in degrees
  5782. * @returns the Angle value in degrees (float)
  5783. */
  5784. degrees(): number;
  5785. /**
  5786. * Get value in radians
  5787. * @returns the Angle value in radians (float)
  5788. */
  5789. radians(): number;
  5790. /**
  5791. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5792. * @param a defines first vector
  5793. * @param b defines second vector
  5794. * @returns a new Angle
  5795. */
  5796. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5797. /**
  5798. * Gets a new Angle object from the given float in radians
  5799. * @param radians defines the angle value in radians
  5800. * @returns a new Angle
  5801. */
  5802. static FromRadians(radians: number): Angle;
  5803. /**
  5804. * Gets a new Angle object from the given float in degrees
  5805. * @param degrees defines the angle value in degrees
  5806. * @returns a new Angle
  5807. */
  5808. static FromDegrees(degrees: number): Angle;
  5809. }
  5810. /**
  5811. * This represents an arc in a 2d space.
  5812. */
  5813. export class Arc2 {
  5814. /** Defines the start point of the arc */
  5815. startPoint: Vector2;
  5816. /** Defines the mid point of the arc */
  5817. midPoint: Vector2;
  5818. /** Defines the end point of the arc */
  5819. endPoint: Vector2;
  5820. /**
  5821. * Defines the center point of the arc.
  5822. */
  5823. centerPoint: Vector2;
  5824. /**
  5825. * Defines the radius of the arc.
  5826. */
  5827. radius: number;
  5828. /**
  5829. * Defines the angle of the arc (from mid point to end point).
  5830. */
  5831. angle: Angle;
  5832. /**
  5833. * Defines the start angle of the arc (from start point to middle point).
  5834. */
  5835. startAngle: Angle;
  5836. /**
  5837. * Defines the orientation of the arc (clock wise/counter clock wise).
  5838. */
  5839. orientation: Orientation;
  5840. /**
  5841. * Creates an Arc object from the three given points : start, middle and end.
  5842. * @param startPoint Defines the start point of the arc
  5843. * @param midPoint Defines the midlle point of the arc
  5844. * @param endPoint Defines the end point of the arc
  5845. */
  5846. constructor(
  5847. /** Defines the start point of the arc */
  5848. startPoint: Vector2,
  5849. /** Defines the mid point of the arc */
  5850. midPoint: Vector2,
  5851. /** Defines the end point of the arc */
  5852. endPoint: Vector2);
  5853. }
  5854. /**
  5855. * Represents a 2D path made up of multiple 2D points
  5856. */
  5857. export class Path2 {
  5858. private _points;
  5859. private _length;
  5860. /**
  5861. * If the path start and end point are the same
  5862. */
  5863. closed: boolean;
  5864. /**
  5865. * Creates a Path2 object from the starting 2D coordinates x and y.
  5866. * @param x the starting points x value
  5867. * @param y the starting points y value
  5868. */
  5869. constructor(x: number, y: number);
  5870. /**
  5871. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5872. * @param x the added points x value
  5873. * @param y the added points y value
  5874. * @returns the updated Path2.
  5875. */
  5876. addLineTo(x: number, y: number): Path2;
  5877. /**
  5878. * 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.
  5879. * @param midX middle point x value
  5880. * @param midY middle point y value
  5881. * @param endX end point x value
  5882. * @param endY end point y value
  5883. * @param numberOfSegments (default: 36)
  5884. * @returns the updated Path2.
  5885. */
  5886. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5887. /**
  5888. * Closes the Path2.
  5889. * @returns the Path2.
  5890. */
  5891. close(): Path2;
  5892. /**
  5893. * Gets the sum of the distance between each sequential point in the path
  5894. * @returns the Path2 total length (float).
  5895. */
  5896. length(): number;
  5897. /**
  5898. * Gets the points which construct the path
  5899. * @returns the Path2 internal array of points.
  5900. */
  5901. getPoints(): Vector2[];
  5902. /**
  5903. * Retreives the point at the distance aways from the starting point
  5904. * @param normalizedLengthPosition the length along the path to retreive the point from
  5905. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5906. */
  5907. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5908. /**
  5909. * Creates a new path starting from an x and y position
  5910. * @param x starting x value
  5911. * @param y starting y value
  5912. * @returns a new Path2 starting at the coordinates (x, y).
  5913. */
  5914. static StartingAt(x: number, y: number): Path2;
  5915. }
  5916. /**
  5917. * Represents a 3D path made up of multiple 3D points
  5918. */
  5919. export class Path3D {
  5920. /**
  5921. * an array of Vector3, the curve axis of the Path3D
  5922. */
  5923. path: Vector3[];
  5924. private _curve;
  5925. private _distances;
  5926. private _tangents;
  5927. private _normals;
  5928. private _binormals;
  5929. private _raw;
  5930. /**
  5931. * new Path3D(path, normal, raw)
  5932. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5933. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5934. * @param path an array of Vector3, the curve axis of the Path3D
  5935. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5936. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5937. */
  5938. constructor(
  5939. /**
  5940. * an array of Vector3, the curve axis of the Path3D
  5941. */
  5942. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5943. /**
  5944. * Returns the Path3D array of successive Vector3 designing its curve.
  5945. * @returns the Path3D array of successive Vector3 designing its curve.
  5946. */
  5947. getCurve(): Vector3[];
  5948. /**
  5949. * Returns an array populated with tangent vectors on each Path3D curve point.
  5950. * @returns an array populated with tangent vectors on each Path3D curve point.
  5951. */
  5952. getTangents(): Vector3[];
  5953. /**
  5954. * Returns an array populated with normal vectors on each Path3D curve point.
  5955. * @returns an array populated with normal vectors on each Path3D curve point.
  5956. */
  5957. getNormals(): Vector3[];
  5958. /**
  5959. * Returns an array populated with binormal vectors on each Path3D curve point.
  5960. * @returns an array populated with binormal vectors on each Path3D curve point.
  5961. */
  5962. getBinormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5965. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5966. */
  5967. getDistances(): number[];
  5968. /**
  5969. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5970. * @param path path which all values are copied into the curves points
  5971. * @param firstNormal which should be projected onto the curve
  5972. * @returns the same object updated.
  5973. */
  5974. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5975. private _compute;
  5976. private _getFirstNonNullVector;
  5977. private _getLastNonNullVector;
  5978. private _normalVector;
  5979. }
  5980. /**
  5981. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5982. * A Curve3 is designed from a series of successive Vector3.
  5983. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5984. */
  5985. export class Curve3 {
  5986. private _points;
  5987. private _length;
  5988. /**
  5989. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5990. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5991. * @param v1 (Vector3) the control point
  5992. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5993. * @param nbPoints (integer) the wanted number of points in the curve
  5994. * @returns the created Curve3
  5995. */
  5996. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5997. /**
  5998. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5999. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6000. * @param v1 (Vector3) the first control point
  6001. * @param v2 (Vector3) the second control point
  6002. * @param v3 (Vector3) the end point of the Cubic Bezier
  6003. * @param nbPoints (integer) the wanted number of points in the curve
  6004. * @returns the created Curve3
  6005. */
  6006. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6007. /**
  6008. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6009. * @param p1 (Vector3) the origin point of the Hermite Spline
  6010. * @param t1 (Vector3) the tangent vector at the origin point
  6011. * @param p2 (Vector3) the end point of the Hermite Spline
  6012. * @param t2 (Vector3) the tangent vector at the end point
  6013. * @param nbPoints (integer) the wanted number of points in the curve
  6014. * @returns the created Curve3
  6015. */
  6016. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6017. /**
  6018. * Returns a Curve3 object along a CatmullRom Spline curve :
  6019. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6020. * @param nbPoints (integer) the wanted number of points between each curve control points
  6021. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6022. * @returns the created Curve3
  6023. */
  6024. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6025. /**
  6026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6027. * A Curve3 is designed from a series of successive Vector3.
  6028. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6029. * @param points points which make up the curve
  6030. */
  6031. constructor(points: Vector3[]);
  6032. /**
  6033. * @returns the Curve3 stored array of successive Vector3
  6034. */
  6035. getPoints(): Vector3[];
  6036. /**
  6037. * @returns the computed length (float) of the curve.
  6038. */
  6039. length(): number;
  6040. /**
  6041. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6042. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6043. * curveA and curveB keep unchanged.
  6044. * @param curve the curve to continue from this curve
  6045. * @returns the newly constructed curve
  6046. */
  6047. continue(curve: DeepImmutable<Curve3>): Curve3;
  6048. private _computeLength;
  6049. }
  6050. }
  6051. declare module BABYLON {
  6052. /**
  6053. * This represents the main contract an easing function should follow.
  6054. * Easing functions are used throughout the animation system.
  6055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6056. */
  6057. export interface IEasingFunction {
  6058. /**
  6059. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6060. * of the easing function.
  6061. * The link below provides some of the most common examples of easing functions.
  6062. * @see https://easings.net/
  6063. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6064. * @returns the corresponding value on the curve defined by the easing function
  6065. */
  6066. ease(gradient: number): number;
  6067. }
  6068. /**
  6069. * Base class used for every default easing function.
  6070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6071. */
  6072. export class EasingFunction implements IEasingFunction {
  6073. /**
  6074. * Interpolation follows the mathematical formula associated with the easing function.
  6075. */
  6076. static readonly EASINGMODE_EASEIN: number;
  6077. /**
  6078. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6079. */
  6080. static readonly EASINGMODE_EASEOUT: number;
  6081. /**
  6082. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6083. */
  6084. static readonly EASINGMODE_EASEINOUT: number;
  6085. private _easingMode;
  6086. /**
  6087. * Sets the easing mode of the current function.
  6088. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6089. */
  6090. setEasingMode(easingMode: number): void;
  6091. /**
  6092. * Gets the current easing mode.
  6093. * @returns the easing mode
  6094. */
  6095. getEasingMode(): number;
  6096. /**
  6097. * @hidden
  6098. */
  6099. easeInCore(gradient: number): number;
  6100. /**
  6101. * Given an input gradient between 0 and 1, this returns the corresponding value
  6102. * of the easing function.
  6103. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6104. * @returns the corresponding value on the curve defined by the easing function
  6105. */
  6106. ease(gradient: number): number;
  6107. }
  6108. /**
  6109. * Easing function with a circle shape (see link below).
  6110. * @see https://easings.net/#easeInCirc
  6111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6112. */
  6113. export class CircleEase extends EasingFunction implements IEasingFunction {
  6114. /** @hidden */
  6115. easeInCore(gradient: number): number;
  6116. }
  6117. /**
  6118. * Easing function with a ease back shape (see link below).
  6119. * @see https://easings.net/#easeInBack
  6120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6121. */
  6122. export class BackEase extends EasingFunction implements IEasingFunction {
  6123. /** Defines the amplitude of the function */
  6124. amplitude: number;
  6125. /**
  6126. * Instantiates a back ease easing
  6127. * @see https://easings.net/#easeInBack
  6128. * @param amplitude Defines the amplitude of the function
  6129. */
  6130. constructor(
  6131. /** Defines the amplitude of the function */
  6132. amplitude?: number);
  6133. /** @hidden */
  6134. easeInCore(gradient: number): number;
  6135. }
  6136. /**
  6137. * Easing function with a bouncing shape (see link below).
  6138. * @see https://easings.net/#easeInBounce
  6139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6140. */
  6141. export class BounceEase extends EasingFunction implements IEasingFunction {
  6142. /** Defines the number of bounces */
  6143. bounces: number;
  6144. /** Defines the amplitude of the bounce */
  6145. bounciness: number;
  6146. /**
  6147. * Instantiates a bounce easing
  6148. * @see https://easings.net/#easeInBounce
  6149. * @param bounces Defines the number of bounces
  6150. * @param bounciness Defines the amplitude of the bounce
  6151. */
  6152. constructor(
  6153. /** Defines the number of bounces */
  6154. bounces?: number,
  6155. /** Defines the amplitude of the bounce */
  6156. bounciness?: number);
  6157. /** @hidden */
  6158. easeInCore(gradient: number): number;
  6159. }
  6160. /**
  6161. * Easing function with a power of 3 shape (see link below).
  6162. * @see https://easings.net/#easeInCubic
  6163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6164. */
  6165. export class CubicEase extends EasingFunction implements IEasingFunction {
  6166. /** @hidden */
  6167. easeInCore(gradient: number): number;
  6168. }
  6169. /**
  6170. * Easing function with an elastic shape (see link below).
  6171. * @see https://easings.net/#easeInElastic
  6172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6173. */
  6174. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6175. /** Defines the number of oscillations*/
  6176. oscillations: number;
  6177. /** Defines the amplitude of the oscillations*/
  6178. springiness: number;
  6179. /**
  6180. * Instantiates an elastic easing function
  6181. * @see https://easings.net/#easeInElastic
  6182. * @param oscillations Defines the number of oscillations
  6183. * @param springiness Defines the amplitude of the oscillations
  6184. */
  6185. constructor(
  6186. /** Defines the number of oscillations*/
  6187. oscillations?: number,
  6188. /** Defines the amplitude of the oscillations*/
  6189. springiness?: number);
  6190. /** @hidden */
  6191. easeInCore(gradient: number): number;
  6192. }
  6193. /**
  6194. * Easing function with an exponential shape (see link below).
  6195. * @see https://easings.net/#easeInExpo
  6196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6197. */
  6198. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6199. /** Defines the exponent of the function */
  6200. exponent: number;
  6201. /**
  6202. * Instantiates an exponential easing function
  6203. * @see https://easings.net/#easeInExpo
  6204. * @param exponent Defines the exponent of the function
  6205. */
  6206. constructor(
  6207. /** Defines the exponent of the function */
  6208. exponent?: number);
  6209. /** @hidden */
  6210. easeInCore(gradient: number): number;
  6211. }
  6212. /**
  6213. * Easing function with a power shape (see link below).
  6214. * @see https://easings.net/#easeInQuad
  6215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6216. */
  6217. export class PowerEase extends EasingFunction implements IEasingFunction {
  6218. /** Defines the power of the function */
  6219. power: number;
  6220. /**
  6221. * Instantiates an power base easing function
  6222. * @see https://easings.net/#easeInQuad
  6223. * @param power Defines the power of the function
  6224. */
  6225. constructor(
  6226. /** Defines the power of the function */
  6227. power?: number);
  6228. /** @hidden */
  6229. easeInCore(gradient: number): number;
  6230. }
  6231. /**
  6232. * Easing function with a power of 2 shape (see link below).
  6233. * @see https://easings.net/#easeInQuad
  6234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6235. */
  6236. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6237. /** @hidden */
  6238. easeInCore(gradient: number): number;
  6239. }
  6240. /**
  6241. * Easing function with a power of 4 shape (see link below).
  6242. * @see https://easings.net/#easeInQuart
  6243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6244. */
  6245. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6246. /** @hidden */
  6247. easeInCore(gradient: number): number;
  6248. }
  6249. /**
  6250. * Easing function with a power of 5 shape (see link below).
  6251. * @see https://easings.net/#easeInQuint
  6252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6253. */
  6254. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6255. /** @hidden */
  6256. easeInCore(gradient: number): number;
  6257. }
  6258. /**
  6259. * Easing function with a sin shape (see link below).
  6260. * @see https://easings.net/#easeInSine
  6261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6262. */
  6263. export class SineEase extends EasingFunction implements IEasingFunction {
  6264. /** @hidden */
  6265. easeInCore(gradient: number): number;
  6266. }
  6267. /**
  6268. * Easing function with a bezier shape (see link below).
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6271. */
  6272. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6273. /** Defines the x component of the start tangent in the bezier curve */
  6274. x1: number;
  6275. /** Defines the y component of the start tangent in the bezier curve */
  6276. y1: number;
  6277. /** Defines the x component of the end tangent in the bezier curve */
  6278. x2: number;
  6279. /** Defines the y component of the end tangent in the bezier curve */
  6280. y2: number;
  6281. /**
  6282. * Instantiates a bezier function
  6283. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6284. * @param x1 Defines the x component of the start tangent in the bezier curve
  6285. * @param y1 Defines the y component of the start tangent in the bezier curve
  6286. * @param x2 Defines the x component of the end tangent in the bezier curve
  6287. * @param y2 Defines the y component of the end tangent in the bezier curve
  6288. */
  6289. constructor(
  6290. /** Defines the x component of the start tangent in the bezier curve */
  6291. x1?: number,
  6292. /** Defines the y component of the start tangent in the bezier curve */
  6293. y1?: number,
  6294. /** Defines the x component of the end tangent in the bezier curve */
  6295. x2?: number,
  6296. /** Defines the y component of the end tangent in the bezier curve */
  6297. y2?: number);
  6298. /** @hidden */
  6299. easeInCore(gradient: number): number;
  6300. }
  6301. }
  6302. declare module BABYLON {
  6303. /**
  6304. * Defines an interface which represents an animation key frame
  6305. */
  6306. export interface IAnimationKey {
  6307. /**
  6308. * Frame of the key frame
  6309. */
  6310. frame: number;
  6311. /**
  6312. * Value at the specifies key frame
  6313. */
  6314. value: any;
  6315. /**
  6316. * The input tangent for the cubic hermite spline
  6317. */
  6318. inTangent?: any;
  6319. /**
  6320. * The output tangent for the cubic hermite spline
  6321. */
  6322. outTangent?: any;
  6323. /**
  6324. * The animation interpolation type
  6325. */
  6326. interpolation?: AnimationKeyInterpolation;
  6327. }
  6328. /**
  6329. * Enum for the animation key frame interpolation type
  6330. */
  6331. export enum AnimationKeyInterpolation {
  6332. /**
  6333. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6334. */
  6335. STEP = 1
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Represents the range of an animation
  6341. */
  6342. export class AnimationRange {
  6343. /**The name of the animation range**/
  6344. name: string;
  6345. /**The starting frame of the animation */
  6346. from: number;
  6347. /**The ending frame of the animation*/
  6348. to: number;
  6349. /**
  6350. * Initializes the range of an animation
  6351. * @param name The name of the animation range
  6352. * @param from The starting frame of the animation
  6353. * @param to The ending frame of the animation
  6354. */
  6355. constructor(
  6356. /**The name of the animation range**/
  6357. name: string,
  6358. /**The starting frame of the animation */
  6359. from: number,
  6360. /**The ending frame of the animation*/
  6361. to: number);
  6362. /**
  6363. * Makes a copy of the animation range
  6364. * @returns A copy of the animation range
  6365. */
  6366. clone(): AnimationRange;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * Composed of a frame, and an action function
  6372. */
  6373. export class AnimationEvent {
  6374. /** The frame for which the event is triggered **/
  6375. frame: number;
  6376. /** The event to perform when triggered **/
  6377. action: (currentFrame: number) => void;
  6378. /** Specifies if the event should be triggered only once**/
  6379. onlyOnce?: boolean | undefined;
  6380. /**
  6381. * Specifies if the animation event is done
  6382. */
  6383. isDone: boolean;
  6384. /**
  6385. * Initializes the animation event
  6386. * @param frame The frame for which the event is triggered
  6387. * @param action The event to perform when triggered
  6388. * @param onlyOnce Specifies if the event should be triggered only once
  6389. */
  6390. constructor(
  6391. /** The frame for which the event is triggered **/
  6392. frame: number,
  6393. /** The event to perform when triggered **/
  6394. action: (currentFrame: number) => void,
  6395. /** Specifies if the event should be triggered only once**/
  6396. onlyOnce?: boolean | undefined);
  6397. /** @hidden */
  6398. _clone(): AnimationEvent;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Interface used to define a behavior
  6404. */
  6405. export interface Behavior<T> {
  6406. /** gets or sets behavior's name */
  6407. name: string;
  6408. /**
  6409. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6410. */
  6411. init(): void;
  6412. /**
  6413. * Called when the behavior is attached to a target
  6414. * @param target defines the target where the behavior is attached to
  6415. */
  6416. attach(target: T): void;
  6417. /**
  6418. * Called when the behavior is detached from its target
  6419. */
  6420. detach(): void;
  6421. }
  6422. /**
  6423. * Interface implemented by classes supporting behaviors
  6424. */
  6425. export interface IBehaviorAware<T> {
  6426. /**
  6427. * Attach a behavior
  6428. * @param behavior defines the behavior to attach
  6429. * @returns the current host
  6430. */
  6431. addBehavior(behavior: Behavior<T>): T;
  6432. /**
  6433. * Remove a behavior from the current object
  6434. * @param behavior defines the behavior to detach
  6435. * @returns the current host
  6436. */
  6437. removeBehavior(behavior: Behavior<T>): T;
  6438. /**
  6439. * Gets a behavior using its name to search
  6440. * @param name defines the name to search
  6441. * @returns the behavior or null if not found
  6442. */
  6443. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Defines an array and its length.
  6449. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6450. */
  6451. export interface ISmartArrayLike<T> {
  6452. /**
  6453. * The data of the array.
  6454. */
  6455. data: Array<T>;
  6456. /**
  6457. * The active length of the array.
  6458. */
  6459. length: number;
  6460. }
  6461. /**
  6462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6463. */
  6464. export class SmartArray<T> implements ISmartArrayLike<T> {
  6465. /**
  6466. * The full set of data from the array.
  6467. */
  6468. data: Array<T>;
  6469. /**
  6470. * The active length of the array.
  6471. */
  6472. length: number;
  6473. protected _id: number;
  6474. /**
  6475. * Instantiates a Smart Array.
  6476. * @param capacity defines the default capacity of the array.
  6477. */
  6478. constructor(capacity: number);
  6479. /**
  6480. * Pushes a value at the end of the active data.
  6481. * @param value defines the object to push in the array.
  6482. */
  6483. push(value: T): void;
  6484. /**
  6485. * Iterates over the active data and apply the lambda to them.
  6486. * @param func defines the action to apply on each value.
  6487. */
  6488. forEach(func: (content: T) => void): void;
  6489. /**
  6490. * Sorts the full sets of data.
  6491. * @param compareFn defines the comparison function to apply.
  6492. */
  6493. sort(compareFn: (a: T, b: T) => number): void;
  6494. /**
  6495. * Resets the active data to an empty array.
  6496. */
  6497. reset(): void;
  6498. /**
  6499. * Releases all the data from the array as well as the array.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Concats the active data with a given array.
  6504. * @param array defines the data to concatenate with.
  6505. */
  6506. concat(array: any): void;
  6507. /**
  6508. * Returns the position of a value in the active data.
  6509. * @param value defines the value to find the index for
  6510. * @returns the index if found in the active data otherwise -1
  6511. */
  6512. indexOf(value: T): number;
  6513. /**
  6514. * Returns whether an element is part of the active data.
  6515. * @param value defines the value to look for
  6516. * @returns true if found in the active data otherwise false
  6517. */
  6518. contains(value: T): boolean;
  6519. private static _GlobalId;
  6520. }
  6521. /**
  6522. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6523. * The data in this array can only be present once
  6524. */
  6525. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6526. private _duplicateId;
  6527. /**
  6528. * Pushes a value at the end of the active data.
  6529. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6530. * @param value defines the object to push in the array.
  6531. */
  6532. push(value: T): void;
  6533. /**
  6534. * Pushes a value at the end of the active data.
  6535. * If the data is already present, it won t be added again
  6536. * @param value defines the object to push in the array.
  6537. * @returns true if added false if it was already present
  6538. */
  6539. pushNoDuplicate(value: T): boolean;
  6540. /**
  6541. * Resets the active data to an empty array.
  6542. */
  6543. reset(): void;
  6544. /**
  6545. * Concats the active data with a given array.
  6546. * This ensures no dupplicate will be present in the result.
  6547. * @param array defines the data to concatenate with.
  6548. */
  6549. concatWithNoDuplicate(array: any): void;
  6550. }
  6551. }
  6552. declare module BABYLON {
  6553. /**
  6554. * @ignore
  6555. * This is a list of all the different input types that are available in the application.
  6556. * Fo instance: ArcRotateCameraGamepadInput...
  6557. */
  6558. export var CameraInputTypes: {};
  6559. /**
  6560. * This is the contract to implement in order to create a new input class.
  6561. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6562. */
  6563. export interface ICameraInput<TCamera extends Camera> {
  6564. /**
  6565. * Defines the camera the input is attached to.
  6566. */
  6567. camera: Nullable<TCamera>;
  6568. /**
  6569. * Gets the class name of the current intput.
  6570. * @returns the class name
  6571. */
  6572. getClassName(): string;
  6573. /**
  6574. * Get the friendly name associated with the input class.
  6575. * @returns the input friendly name
  6576. */
  6577. getSimpleName(): string;
  6578. /**
  6579. * Attach the input controls to a specific dom element to get the input from.
  6580. * @param element Defines the element the controls should be listened from
  6581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6582. */
  6583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6584. /**
  6585. * Detach the current controls from the specified dom element.
  6586. * @param element Defines the element to stop listening the inputs from
  6587. */
  6588. detachControl(element: Nullable<HTMLElement>): void;
  6589. /**
  6590. * Update the current camera state depending on the inputs that have been used this frame.
  6591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6592. */
  6593. checkInputs?: () => void;
  6594. }
  6595. /**
  6596. * Represents a map of input types to input instance or input index to input instance.
  6597. */
  6598. export interface CameraInputsMap<TCamera extends Camera> {
  6599. /**
  6600. * Accessor to the input by input type.
  6601. */
  6602. [name: string]: ICameraInput<TCamera>;
  6603. /**
  6604. * Accessor to the input by input index.
  6605. */
  6606. [idx: number]: ICameraInput<TCamera>;
  6607. }
  6608. /**
  6609. * This represents the input manager used within a camera.
  6610. * It helps dealing with all the different kind of input attached to a camera.
  6611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6612. */
  6613. export class CameraInputsManager<TCamera extends Camera> {
  6614. /**
  6615. * Defines the list of inputs attahed to the camera.
  6616. */
  6617. attached: CameraInputsMap<TCamera>;
  6618. /**
  6619. * Defines the dom element the camera is collecting inputs from.
  6620. * This is null if the controls have not been attached.
  6621. */
  6622. attachedElement: Nullable<HTMLElement>;
  6623. /**
  6624. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6625. */
  6626. noPreventDefault: boolean;
  6627. /**
  6628. * Defined the camera the input manager belongs to.
  6629. */
  6630. camera: TCamera;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs: () => void;
  6636. /**
  6637. * Instantiate a new Camera Input Manager.
  6638. * @param camera Defines the camera the input manager blongs to
  6639. */
  6640. constructor(camera: TCamera);
  6641. /**
  6642. * Add an input method to a camera
  6643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6644. * @param input camera input method
  6645. */
  6646. add(input: ICameraInput<TCamera>): void;
  6647. /**
  6648. * Remove a specific input method from a camera
  6649. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6650. * @param inputToRemove camera input method
  6651. */
  6652. remove(inputToRemove: ICameraInput<TCamera>): void;
  6653. /**
  6654. * Remove a specific input type from a camera
  6655. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6656. * @param inputType the type of the input to remove
  6657. */
  6658. removeByType(inputType: string): void;
  6659. private _addCheckInputs;
  6660. /**
  6661. * Attach the input controls to the currently attached dom element to listen the events from.
  6662. * @param input Defines the input to attach
  6663. */
  6664. attachInput(input: ICameraInput<TCamera>): void;
  6665. /**
  6666. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6667. * @param element Defines the dom element to collect the events from
  6668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6669. */
  6670. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6671. /**
  6672. * Detach the current manager inputs controls from a specific dom element.
  6673. * @param element Defines the dom element to collect the events from
  6674. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6675. */
  6676. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6677. /**
  6678. * Rebuild the dynamic inputCheck function from the current list of
  6679. * defined inputs in the manager.
  6680. */
  6681. rebuildInputCheck(): void;
  6682. /**
  6683. * Remove all attached input methods from a camera
  6684. */
  6685. clear(): void;
  6686. /**
  6687. * Serialize the current input manager attached to a camera.
  6688. * This ensures than once parsed,
  6689. * the input associated to the camera will be identical to the current ones
  6690. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6691. */
  6692. serialize(serializedCamera: any): void;
  6693. /**
  6694. * Parses an input manager serialized JSON to restore the previous list of inputs
  6695. * and states associated to a camera.
  6696. * @param parsedCamera Defines the JSON to parse
  6697. */
  6698. parse(parsedCamera: any): void;
  6699. }
  6700. }
  6701. declare module BABYLON {
  6702. /**
  6703. * @hidden
  6704. */
  6705. export class IntersectionInfo {
  6706. bu: Nullable<number>;
  6707. bv: Nullable<number>;
  6708. distance: number;
  6709. faceId: number;
  6710. subMeshId: number;
  6711. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6712. }
  6713. }
  6714. declare module BABYLON {
  6715. /**
  6716. * Represens a plane by the equation ax + by + cz + d = 0
  6717. */
  6718. export class Plane {
  6719. private static _TmpMatrix;
  6720. /**
  6721. * Normal of the plane (a,b,c)
  6722. */
  6723. normal: Vector3;
  6724. /**
  6725. * d component of the plane
  6726. */
  6727. d: number;
  6728. /**
  6729. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6730. * @param a a component of the plane
  6731. * @param b b component of the plane
  6732. * @param c c component of the plane
  6733. * @param d d component of the plane
  6734. */
  6735. constructor(a: number, b: number, c: number, d: number);
  6736. /**
  6737. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6738. */
  6739. asArray(): number[];
  6740. /**
  6741. * @returns a new plane copied from the current Plane.
  6742. */
  6743. clone(): Plane;
  6744. /**
  6745. * @returns the string "Plane".
  6746. */
  6747. getClassName(): string;
  6748. /**
  6749. * @returns the Plane hash code.
  6750. */
  6751. getHashCode(): number;
  6752. /**
  6753. * Normalize the current Plane in place.
  6754. * @returns the updated Plane.
  6755. */
  6756. normalize(): Plane;
  6757. /**
  6758. * Applies a transformation the plane and returns the result
  6759. * @param transformation the transformation matrix to be applied to the plane
  6760. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6761. */
  6762. transform(transformation: DeepImmutable<Matrix>): Plane;
  6763. /**
  6764. * Calcualtte the dot product between the point and the plane normal
  6765. * @param point point to calculate the dot product with
  6766. * @returns the dot product (float) of the point coordinates and the plane normal.
  6767. */
  6768. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6769. /**
  6770. * Updates the current Plane from the plane defined by the three given points.
  6771. * @param point1 one of the points used to contruct the plane
  6772. * @param point2 one of the points used to contruct the plane
  6773. * @param point3 one of the points used to contruct the plane
  6774. * @returns the updated Plane.
  6775. */
  6776. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6777. /**
  6778. * Checks if the plane is facing a given direction
  6779. * @param direction the direction to check if the plane is facing
  6780. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6781. * @returns True is the vector "direction" is the same side than the plane normal.
  6782. */
  6783. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6784. /**
  6785. * Calculates the distance to a point
  6786. * @param point point to calculate distance to
  6787. * @returns the signed distance (float) from the given point to the Plane.
  6788. */
  6789. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6790. /**
  6791. * Creates a plane from an array
  6792. * @param array the array to create a plane from
  6793. * @returns a new Plane from the given array.
  6794. */
  6795. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6796. /**
  6797. * Creates a plane from three points
  6798. * @param point1 point used to create the plane
  6799. * @param point2 point used to create the plane
  6800. * @param point3 point used to create the plane
  6801. * @returns a new Plane defined by the three given points.
  6802. */
  6803. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6804. /**
  6805. * Creates a plane from an origin point and a normal
  6806. * @param origin origin of the plane to be constructed
  6807. * @param normal normal of the plane to be constructed
  6808. * @returns a new Plane the normal vector to this plane at the given origin point.
  6809. * Note : the vector "normal" is updated because normalized.
  6810. */
  6811. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6812. /**
  6813. * Calculates the distance from a plane and a point
  6814. * @param origin origin of the plane to be constructed
  6815. * @param normal normal of the plane to be constructed
  6816. * @param point point to calculate distance to
  6817. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6818. */
  6819. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6820. }
  6821. }
  6822. declare module BABYLON {
  6823. /**
  6824. * Class used to store bounding sphere information
  6825. */
  6826. export class BoundingSphere {
  6827. /**
  6828. * Gets the center of the bounding sphere in local space
  6829. */
  6830. readonly center: Vector3;
  6831. /**
  6832. * Radius of the bounding sphere in local space
  6833. */
  6834. radius: number;
  6835. /**
  6836. * Gets the center of the bounding sphere in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in world space
  6841. */
  6842. radiusWorld: number;
  6843. /**
  6844. * Gets the minimum vector in local space
  6845. */
  6846. readonly minimum: Vector3;
  6847. /**
  6848. * Gets the maximum vector in local space
  6849. */
  6850. readonly maximum: Vector3;
  6851. private _worldMatrix;
  6852. private static readonly TmpVector3;
  6853. /**
  6854. * Creates a new bounding sphere
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding sphere by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingSphere;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding sphere is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding sphere center is in between the frustum planes.
  6888. * Used for optimistic fast inclusion.
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if the sphere center is in between the frustum planes
  6891. */
  6892. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if a point is inside the bounding sphere
  6895. * @param point defines the point to test
  6896. * @returns true if the point is inside the bounding sphere
  6897. */
  6898. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6899. /**
  6900. * Checks if two sphere intersct
  6901. * @param sphere0 sphere 0
  6902. * @param sphere1 sphere 1
  6903. * @returns true if the speres intersect
  6904. */
  6905. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding box information
  6911. */
  6912. export class BoundingBox implements ICullable {
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in local space
  6915. */
  6916. readonly vectors: Vector3[];
  6917. /**
  6918. * Gets the center of the bounding box in local space
  6919. */
  6920. readonly center: Vector3;
  6921. /**
  6922. * Gets the center of the bounding box in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Gets the extend size in local space
  6927. */
  6928. readonly extendSize: Vector3;
  6929. /**
  6930. * Gets the extend size in world space
  6931. */
  6932. readonly extendSizeWorld: Vector3;
  6933. /**
  6934. * Gets the OBB (object bounding box) directions
  6935. */
  6936. readonly directions: Vector3[];
  6937. /**
  6938. * Gets the 8 vectors representing the bounding box in world space
  6939. */
  6940. readonly vectorsWorld: Vector3[];
  6941. /**
  6942. * Gets the minimum vector in world space
  6943. */
  6944. readonly minimumWorld: Vector3;
  6945. /**
  6946. * Gets the maximum vector in world space
  6947. */
  6948. readonly maximumWorld: Vector3;
  6949. /**
  6950. * Gets the minimum vector in local space
  6951. */
  6952. readonly minimum: Vector3;
  6953. /**
  6954. * Gets the maximum vector in local space
  6955. */
  6956. readonly maximum: Vector3;
  6957. private _worldMatrix;
  6958. private static readonly TmpVector3;
  6959. /**
  6960. * @hidden
  6961. */
  6962. _tag: number;
  6963. /**
  6964. * Creates a new bounding box
  6965. * @param min defines the minimum vector (in local space)
  6966. * @param max defines the maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6970. /**
  6971. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6972. * @param min defines the new minimum vector (in local space)
  6973. * @param max defines the new maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6977. /**
  6978. * Scale the current bounding box by applying a scale factor
  6979. * @param factor defines the scale factor to apply
  6980. * @returns the current bounding box
  6981. */
  6982. scale(factor: number): BoundingBox;
  6983. /**
  6984. * Gets the world matrix of the bounding box
  6985. * @returns a matrix
  6986. */
  6987. getWorldMatrix(): DeepImmutable<Matrix>;
  6988. /** @hidden */
  6989. _update(world: DeepImmutable<Matrix>): void;
  6990. /**
  6991. * Tests if the bounding box is intersecting the frustum planes
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if the bounding box is entirely inside the frustum planes
  6998. * @param frustumPlanes defines the frustum planes to test
  6999. * @returns true if there is an inclusion
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /**
  7003. * Tests if a point is inside the bounding box
  7004. * @param point defines the point to test
  7005. * @returns true if the point is inside the bounding box
  7006. */
  7007. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7008. /**
  7009. * Tests if the bounding box intersects with a bounding sphere
  7010. * @param sphere defines the sphere to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7014. /**
  7015. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7016. * @param min defines the min vector to use
  7017. * @param max defines the max vector to use
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Tests if two bounding boxes are intersections
  7023. * @param box0 defines the first box to test
  7024. * @param box1 defines the second box to test
  7025. * @returns true if there is an intersection
  7026. */
  7027. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7028. /**
  7029. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7030. * @param minPoint defines the minimum vector of the bounding box
  7031. * @param maxPoint defines the maximum vector of the bounding box
  7032. * @param sphereCenter defines the sphere center
  7033. * @param sphereRadius defines the sphere radius
  7034. * @returns true if there is an intersection
  7035. */
  7036. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an inclusion
  7042. */
  7043. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an intersection
  7049. */
  7050. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /** @hidden */
  7055. export class Collider {
  7056. /** Define if a collision was found */
  7057. collisionFound: boolean;
  7058. /**
  7059. * Define last intersection point in local space
  7060. */
  7061. intersectionPoint: Vector3;
  7062. /**
  7063. * Define last collided mesh
  7064. */
  7065. collidedMesh: Nullable<AbstractMesh>;
  7066. private _collisionPoint;
  7067. private _planeIntersectionPoint;
  7068. private _tempVector;
  7069. private _tempVector2;
  7070. private _tempVector3;
  7071. private _tempVector4;
  7072. private _edge;
  7073. private _baseToVertex;
  7074. private _destinationPoint;
  7075. private _slidePlaneNormal;
  7076. private _displacementVector;
  7077. /** @hidden */
  7078. _radius: Vector3;
  7079. /** @hidden */
  7080. _retry: number;
  7081. private _velocity;
  7082. private _basePoint;
  7083. private _epsilon;
  7084. /** @hidden */
  7085. _velocityWorldLength: number;
  7086. /** @hidden */
  7087. _basePointWorld: Vector3;
  7088. private _velocityWorld;
  7089. private _normalizedVelocity;
  7090. /** @hidden */
  7091. _initialVelocity: Vector3;
  7092. /** @hidden */
  7093. _initialPosition: Vector3;
  7094. private _nearestDistance;
  7095. private _collisionMask;
  7096. collisionMask: number;
  7097. /**
  7098. * Gets the plane normal used to compute the sliding response (in local space)
  7099. */
  7100. readonly slidePlaneNormal: Vector3;
  7101. /** @hidden */
  7102. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7103. /** @hidden */
  7104. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7105. /** @hidden */
  7106. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7107. /** @hidden */
  7108. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7111. /** @hidden */
  7112. _getResponse(pos: Vector3, vel: Vector3): void;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /**
  7117. * Interface for cullable objects
  7118. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7119. */
  7120. export interface ICullable {
  7121. /**
  7122. * Checks if the object or part of the object is in the frustum
  7123. * @param frustumPlanes Camera near/planes
  7124. * @returns true if the object is in frustum otherwise false
  7125. */
  7126. isInFrustum(frustumPlanes: Plane[]): boolean;
  7127. /**
  7128. * Checks if a cullable object (mesh...) is in the camera frustum
  7129. * Unlike isInFrustum this cheks the full bounding box
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7134. }
  7135. /**
  7136. * Info for a bounding data of a mesh
  7137. */
  7138. export class BoundingInfo implements ICullable {
  7139. /**
  7140. * Bounding box for the mesh
  7141. */
  7142. readonly boundingBox: BoundingBox;
  7143. /**
  7144. * Bounding sphere for the mesh
  7145. */
  7146. readonly boundingSphere: BoundingSphere;
  7147. private _isLocked;
  7148. private static readonly TmpVector3;
  7149. /**
  7150. * Constructs bounding info
  7151. * @param minimum min vector of the bounding box/sphere
  7152. * @param maximum max vector of the bounding box/sphere
  7153. * @param worldMatrix defines the new world matrix
  7154. */
  7155. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7156. /**
  7157. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7158. * @param min defines the new minimum vector (in local space)
  7159. * @param max defines the new maximum vector (in local space)
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7163. /**
  7164. * min vector of the bounding box/sphere
  7165. */
  7166. readonly minimum: Vector3;
  7167. /**
  7168. * max vector of the bounding box/sphere
  7169. */
  7170. readonly maximum: Vector3;
  7171. /**
  7172. * If the info is locked and won't be updated to avoid perf overhead
  7173. */
  7174. isLocked: boolean;
  7175. /**
  7176. * Updates the bounding sphere and box
  7177. * @param world world matrix to be used to update
  7178. */
  7179. update(world: DeepImmutable<Matrix>): void;
  7180. /**
  7181. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7182. * @param center New center of the bounding info
  7183. * @param extend New extend of the bounding info
  7184. * @returns the current bounding info
  7185. */
  7186. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7187. /**
  7188. * Scale the current bounding info by applying a scale factor
  7189. * @param factor defines the scale factor to apply
  7190. * @returns the current bounding info
  7191. */
  7192. scale(factor: number): BoundingInfo;
  7193. /**
  7194. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7195. * @param frustumPlanes defines the frustum to test
  7196. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7197. * @returns true if the bounding info is in the frustum planes
  7198. */
  7199. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7200. /**
  7201. * Gets the world distance between the min and max points of the bounding box
  7202. */
  7203. readonly diagonalLength: number;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /** @hidden */
  7212. _checkCollision(collider: Collider): boolean;
  7213. /**
  7214. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7215. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7216. * @param point the point to check intersection with
  7217. * @returns if the point intersects
  7218. */
  7219. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7220. /**
  7221. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param boundingInfo the bounding info to check intersection with
  7224. * @param precise if the intersection should be done using OBB
  7225. * @returns if the bounding info intersects
  7226. */
  7227. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Extracts minimum and maximum values from a list of indexed positions
  7233. * @param positions defines the positions to use
  7234. * @param indices defines the indices to the positions
  7235. * @param indexStart defines the start index
  7236. * @param indexCount defines the end index
  7237. * @param bias defines bias value to add to the result
  7238. * @return minimum and maximum values
  7239. */
  7240. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7241. minimum: Vector3;
  7242. maximum: Vector3;
  7243. };
  7244. /**
  7245. * Extracts minimum and maximum values from a list of positions
  7246. * @param positions defines the positions to use
  7247. * @param start defines the start index in the positions array
  7248. * @param count defines the number of positions to handle
  7249. * @param bias defines bias value to add to the result
  7250. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7251. * @return minimum and maximum values
  7252. */
  7253. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7254. minimum: Vector3;
  7255. maximum: Vector3;
  7256. };
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Enum that determines the text-wrapping mode to use.
  7261. */
  7262. export enum InspectableType {
  7263. /**
  7264. * Checkbox for booleans
  7265. */
  7266. Checkbox = 0,
  7267. /**
  7268. * Sliders for numbers
  7269. */
  7270. Slider = 1,
  7271. /**
  7272. * Vector3
  7273. */
  7274. Vector3 = 2,
  7275. /**
  7276. * Quaternions
  7277. */
  7278. Quaternion = 3,
  7279. /**
  7280. * Color3
  7281. */
  7282. Color3 = 4,
  7283. /**
  7284. * String
  7285. */
  7286. String = 5
  7287. }
  7288. /**
  7289. * Interface used to define custom inspectable properties.
  7290. * This interface is used by the inspector to display custom property grids
  7291. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7292. */
  7293. export interface IInspectable {
  7294. /**
  7295. * Gets the label to display
  7296. */
  7297. label: string;
  7298. /**
  7299. * Gets the name of the property to edit
  7300. */
  7301. propertyName: string;
  7302. /**
  7303. * Gets the type of the editor to use
  7304. */
  7305. type: InspectableType;
  7306. /**
  7307. * Gets the minimum value of the property when using in "slider" mode
  7308. */
  7309. min?: number;
  7310. /**
  7311. * Gets the maximum value of the property when using in "slider" mode
  7312. */
  7313. max?: number;
  7314. /**
  7315. * Gets the setp to use when using in "slider" mode
  7316. */
  7317. step?: number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Class used to provide helper for timing
  7323. */
  7324. export class TimingTools {
  7325. /**
  7326. * Polyfill for setImmediate
  7327. * @param action defines the action to execute after the current execution block
  7328. */
  7329. static SetImmediate(action: () => void): void;
  7330. }
  7331. }
  7332. declare module BABYLON {
  7333. /**
  7334. * Class used to enable instatition of objects by class name
  7335. */
  7336. export class InstantiationTools {
  7337. /**
  7338. * Use this object to register external classes like custom textures or material
  7339. * to allow the laoders to instantiate them
  7340. */
  7341. static RegisteredExternalClasses: {
  7342. [key: string]: Object;
  7343. };
  7344. /**
  7345. * Tries to instantiate a new object from a given class name
  7346. * @param className defines the class name to instantiate
  7347. * @returns the new object or null if the system was not able to do the instantiation
  7348. */
  7349. static Instantiate(className: string): any;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * This represents the required contract to create a new type of texture loader.
  7355. */
  7356. export interface IInternalTextureLoader {
  7357. /**
  7358. * Defines wether the loader supports cascade loading the different faces.
  7359. */
  7360. supportCascades: boolean;
  7361. /**
  7362. * This returns if the loader support the current file information.
  7363. * @param extension defines the file extension of the file being loaded
  7364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7365. * @param fallback defines the fallback internal texture if any
  7366. * @param isBase64 defines whether the texture is encoded as a base64
  7367. * @param isBuffer defines whether the texture data are stored as a buffer
  7368. * @returns true if the loader can load the specified file
  7369. */
  7370. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7371. /**
  7372. * Transform the url before loading if required.
  7373. * @param rootUrl the url of the texture
  7374. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7375. * @returns the transformed texture
  7376. */
  7377. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7378. /**
  7379. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7380. * @param rootUrl the url of the texture
  7381. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7382. * @returns the fallback texture
  7383. */
  7384. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7385. /**
  7386. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7387. * @param data contains the texture data
  7388. * @param texture defines the BabylonJS internal texture
  7389. * @param createPolynomials will be true if polynomials have been requested
  7390. * @param onLoad defines the callback to trigger once the texture is ready
  7391. * @param onError defines the callback to trigger in case of error
  7392. */
  7393. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7394. /**
  7395. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7396. * @param data contains the texture data
  7397. * @param texture defines the BabylonJS internal texture
  7398. * @param callback defines the method to call once ready to upload
  7399. */
  7400. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. interface Engine {
  7405. /**
  7406. * Creates a depth stencil cube texture.
  7407. * This is only available in WebGL 2.
  7408. * @param size The size of face edge in the cube texture.
  7409. * @param options The options defining the cube texture.
  7410. * @returns The cube texture
  7411. */
  7412. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7413. /**
  7414. * Creates a cube texture
  7415. * @param rootUrl defines the url where the files to load is located
  7416. * @param scene defines the current scene
  7417. * @param files defines the list of files to load (1 per face)
  7418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7419. * @param onLoad defines an optional callback raised when the texture is loaded
  7420. * @param onError defines an optional callback raised if there is an issue to load the texture
  7421. * @param format defines the format of the data
  7422. * @param forcedExtension defines the extension to use to pick the right loader
  7423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7428. * @returns the cube texture as an InternalTexture
  7429. */
  7430. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7431. /**
  7432. * Creates a cube texture
  7433. * @param rootUrl defines the url where the files to load is located
  7434. * @param scene defines the current scene
  7435. * @param files defines the list of files to load (1 per face)
  7436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7437. * @param onLoad defines an optional callback raised when the texture is loaded
  7438. * @param onError defines an optional callback raised if there is an issue to load the texture
  7439. * @param format defines the format of the data
  7440. * @param forcedExtension defines the extension to use to pick the right loader
  7441. * @returns the cube texture as an InternalTexture
  7442. */
  7443. 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;
  7444. /**
  7445. * Creates a cube texture
  7446. * @param rootUrl defines the url where the files to load is located
  7447. * @param scene defines the current scene
  7448. * @param files defines the list of files to load (1 per face)
  7449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7450. * @param onLoad defines an optional callback raised when the texture is loaded
  7451. * @param onError defines an optional callback raised if there is an issue to load the texture
  7452. * @param format defines the format of the data
  7453. * @param forcedExtension defines the extension to use to pick the right loader
  7454. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7457. * @returns the cube texture as an InternalTexture
  7458. */
  7459. 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;
  7460. /** @hidden */
  7461. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7462. /** @hidden */
  7463. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7464. /** @hidden */
  7465. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /** @hidden */
  7467. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7468. }
  7469. }
  7470. declare module BABYLON {
  7471. /**
  7472. * Class for creating a cube texture
  7473. */
  7474. export class CubeTexture extends BaseTexture {
  7475. private _delayedOnLoad;
  7476. /**
  7477. * The url of the texture
  7478. */
  7479. url: string;
  7480. /**
  7481. * Gets or sets the center of the bounding box associated with the cube texture.
  7482. * It must define where the camera used to render the texture was set
  7483. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7484. */
  7485. boundingBoxPosition: Vector3;
  7486. private _boundingBoxSize;
  7487. /**
  7488. * Gets or sets the size of the bounding box associated with the cube texture
  7489. * When defined, the cubemap will switch to local mode
  7490. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7491. * @example https://www.babylonjs-playground.com/#RNASML
  7492. */
  7493. /**
  7494. * Returns the bounding box size
  7495. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7496. */
  7497. boundingBoxSize: Vector3;
  7498. protected _rotationY: number;
  7499. /**
  7500. * Sets texture matrix rotation angle around Y axis in radians.
  7501. */
  7502. /**
  7503. * Gets texture matrix rotation angle around Y axis radians.
  7504. */
  7505. rotationY: number;
  7506. /**
  7507. * Are mip maps generated for this texture or not.
  7508. */
  7509. readonly noMipmap: boolean;
  7510. private _noMipmap;
  7511. private _files;
  7512. private _extensions;
  7513. private _textureMatrix;
  7514. private _format;
  7515. private _createPolynomials;
  7516. /** @hidden */
  7517. _prefiltered: boolean;
  7518. /**
  7519. * Creates a cube texture from an array of image urls
  7520. * @param files defines an array of image urls
  7521. * @param scene defines the hosting scene
  7522. * @param noMipmap specifies if mip maps are not used
  7523. * @returns a cube texture
  7524. */
  7525. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7526. /**
  7527. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7528. * @param url defines the url of the prefiltered texture
  7529. * @param scene defines the scene the texture is attached to
  7530. * @param forcedExtension defines the extension of the file if different from the url
  7531. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7532. * @return the prefiltered texture
  7533. */
  7534. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7535. /**
  7536. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7537. * as prefiltered data.
  7538. * @param rootUrl defines the url of the texture or the root name of the six images
  7539. * @param scene defines the scene the texture is attached to
  7540. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7541. * @param noMipmap defines if mipmaps should be created or not
  7542. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7543. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7544. * @param onError defines a callback triggered in case of error during load
  7545. * @param format defines the internal format to use for the texture once loaded
  7546. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7547. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7548. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7551. * @return the cube texture
  7552. */
  7553. 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);
  7554. /**
  7555. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7556. */
  7557. readonly isPrefiltered: boolean;
  7558. /**
  7559. * Get the current class name of the texture useful for serialization or dynamic coding.
  7560. * @returns "CubeTexture"
  7561. */
  7562. getClassName(): string;
  7563. /**
  7564. * Update the url (and optional buffer) of this texture if url was null during construction.
  7565. * @param url the url of the texture
  7566. * @param forcedExtension defines the extension to use
  7567. * @param onLoad callback called when the texture is loaded (defaults to null)
  7568. */
  7569. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7570. /**
  7571. * Delays loading of the cube texture
  7572. * @param forcedExtension defines the extension to use
  7573. */
  7574. delayLoad(forcedExtension?: string): void;
  7575. /**
  7576. * Returns the reflection texture matrix
  7577. * @returns the reflection texture matrix
  7578. */
  7579. getReflectionTextureMatrix(): Matrix;
  7580. /**
  7581. * Sets the reflection texture matrix
  7582. * @param value Reflection texture matrix
  7583. */
  7584. setReflectionTextureMatrix(value: Matrix): void;
  7585. /**
  7586. * Parses text to create a cube texture
  7587. * @param parsedTexture define the serialized text to read from
  7588. * @param scene defines the hosting scene
  7589. * @param rootUrl defines the root url of the cube texture
  7590. * @returns a cube texture
  7591. */
  7592. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7593. /**
  7594. * Makes a clone, or deep copy, of the cube texture
  7595. * @returns a new cube texture
  7596. */
  7597. clone(): CubeTexture;
  7598. }
  7599. }
  7600. declare module BABYLON {
  7601. /**
  7602. * Manages the defines for the Material
  7603. */
  7604. export class MaterialDefines {
  7605. /** @hidden */
  7606. protected _keys: string[];
  7607. private _isDirty;
  7608. /** @hidden */
  7609. _renderId: number;
  7610. /** @hidden */
  7611. _areLightsDirty: boolean;
  7612. /** @hidden */
  7613. _areLightsDisposed: boolean;
  7614. /** @hidden */
  7615. _areAttributesDirty: boolean;
  7616. /** @hidden */
  7617. _areTexturesDirty: boolean;
  7618. /** @hidden */
  7619. _areFresnelDirty: boolean;
  7620. /** @hidden */
  7621. _areMiscDirty: boolean;
  7622. /** @hidden */
  7623. _areImageProcessingDirty: boolean;
  7624. /** @hidden */
  7625. _normals: boolean;
  7626. /** @hidden */
  7627. _uvs: boolean;
  7628. /** @hidden */
  7629. _needNormals: boolean;
  7630. /** @hidden */
  7631. _needUVs: boolean;
  7632. [id: string]: any;
  7633. /**
  7634. * Specifies if the material needs to be re-calculated
  7635. */
  7636. readonly isDirty: boolean;
  7637. /**
  7638. * Marks the material to indicate that it has been re-calculated
  7639. */
  7640. markAsProcessed(): void;
  7641. /**
  7642. * Marks the material to indicate that it needs to be re-calculated
  7643. */
  7644. markAsUnprocessed(): void;
  7645. /**
  7646. * Marks the material to indicate all of its defines need to be re-calculated
  7647. */
  7648. markAllAsDirty(): void;
  7649. /**
  7650. * Marks the material to indicate that image processing needs to be re-calculated
  7651. */
  7652. markAsImageProcessingDirty(): void;
  7653. /**
  7654. * Marks the material to indicate the lights need to be re-calculated
  7655. * @param disposed Defines whether the light is dirty due to dispose or not
  7656. */
  7657. markAsLightDirty(disposed?: boolean): void;
  7658. /**
  7659. * Marks the attribute state as changed
  7660. */
  7661. markAsAttributesDirty(): void;
  7662. /**
  7663. * Marks the texture state as changed
  7664. */
  7665. markAsTexturesDirty(): void;
  7666. /**
  7667. * Marks the fresnel state as changed
  7668. */
  7669. markAsFresnelDirty(): void;
  7670. /**
  7671. * Marks the misc state as changed
  7672. */
  7673. markAsMiscDirty(): void;
  7674. /**
  7675. * Rebuilds the material defines
  7676. */
  7677. rebuild(): void;
  7678. /**
  7679. * Specifies if two material defines are equal
  7680. * @param other - A material define instance to compare to
  7681. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7682. */
  7683. isEqual(other: MaterialDefines): boolean;
  7684. /**
  7685. * Clones this instance's defines to another instance
  7686. * @param other - material defines to clone values to
  7687. */
  7688. cloneTo(other: MaterialDefines): void;
  7689. /**
  7690. * Resets the material define values
  7691. */
  7692. reset(): void;
  7693. /**
  7694. * Converts the material define values to a string
  7695. * @returns - String of material define information
  7696. */
  7697. toString(): string;
  7698. }
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7704. * 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;
  7705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7706. */
  7707. export class ColorCurves {
  7708. private _dirty;
  7709. private _tempColor;
  7710. private _globalCurve;
  7711. private _highlightsCurve;
  7712. private _midtonesCurve;
  7713. private _shadowsCurve;
  7714. private _positiveCurve;
  7715. private _negativeCurve;
  7716. private _globalHue;
  7717. private _globalDensity;
  7718. private _globalSaturation;
  7719. private _globalExposure;
  7720. /**
  7721. * Gets the global Hue value.
  7722. * 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).
  7723. */
  7724. /**
  7725. * Sets the global Hue value.
  7726. * 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).
  7727. */
  7728. globalHue: number;
  7729. /**
  7730. * Gets the global Density value.
  7731. * 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.
  7732. * Values less than zero provide a filter of opposite hue.
  7733. */
  7734. /**
  7735. * Sets the global Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. globalDensity: number;
  7740. /**
  7741. * Gets the global Saturation value.
  7742. * 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.
  7743. */
  7744. /**
  7745. * Sets the global Saturation value.
  7746. * 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.
  7747. */
  7748. globalSaturation: number;
  7749. /**
  7750. * Gets the global Exposure value.
  7751. * 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.
  7752. */
  7753. /**
  7754. * Sets the global Exposure value.
  7755. * 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.
  7756. */
  7757. globalExposure: number;
  7758. private _highlightsHue;
  7759. private _highlightsDensity;
  7760. private _highlightsSaturation;
  7761. private _highlightsExposure;
  7762. /**
  7763. * Gets the highlights Hue value.
  7764. * 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).
  7765. */
  7766. /**
  7767. * Sets the highlights Hue value.
  7768. * 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).
  7769. */
  7770. highlightsHue: number;
  7771. /**
  7772. * Gets the highlights Density value.
  7773. * 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.
  7774. * Values less than zero provide a filter of opposite hue.
  7775. */
  7776. /**
  7777. * Sets the highlights Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. highlightsDensity: number;
  7782. /**
  7783. * Gets the highlights Saturation value.
  7784. * 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.
  7785. */
  7786. /**
  7787. * Sets the highlights Saturation value.
  7788. * 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.
  7789. */
  7790. highlightsSaturation: number;
  7791. /**
  7792. * Gets the highlights Exposure value.
  7793. * 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.
  7794. */
  7795. /**
  7796. * Sets the highlights Exposure value.
  7797. * 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.
  7798. */
  7799. highlightsExposure: number;
  7800. private _midtonesHue;
  7801. private _midtonesDensity;
  7802. private _midtonesSaturation;
  7803. private _midtonesExposure;
  7804. /**
  7805. * Gets the midtones Hue value.
  7806. * 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).
  7807. */
  7808. /**
  7809. * Sets the midtones Hue value.
  7810. * 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).
  7811. */
  7812. midtonesHue: number;
  7813. /**
  7814. * Gets the midtones Density value.
  7815. * 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.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the midtones Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. midtonesDensity: number;
  7824. /**
  7825. * Gets the midtones Saturation value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the midtones Saturation value.
  7830. * 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.
  7831. */
  7832. midtonesSaturation: number;
  7833. /**
  7834. * Gets the midtones Exposure value.
  7835. * 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.
  7836. */
  7837. /**
  7838. * Sets the midtones Exposure value.
  7839. * 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.
  7840. */
  7841. midtonesExposure: number;
  7842. private _shadowsHue;
  7843. private _shadowsDensity;
  7844. private _shadowsSaturation;
  7845. private _shadowsExposure;
  7846. /**
  7847. * Gets the shadows Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the shadows Hue value.
  7852. * 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).
  7853. */
  7854. shadowsHue: number;
  7855. /**
  7856. * Gets the shadows Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the shadows Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. shadowsDensity: number;
  7866. /**
  7867. * Gets the shadows Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the shadows Saturation value.
  7872. * 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.
  7873. */
  7874. shadowsSaturation: number;
  7875. /**
  7876. * Gets the shadows Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the shadows Exposure value.
  7881. * 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.
  7882. */
  7883. shadowsExposure: number;
  7884. /**
  7885. * Returns the class name
  7886. * @returns The class name
  7887. */
  7888. getClassName(): string;
  7889. /**
  7890. * Binds the color curves to the shader.
  7891. * @param colorCurves The color curve to bind
  7892. * @param effect The effect to bind to
  7893. * @param positiveUniform The positive uniform shader parameter
  7894. * @param neutralUniform The neutral uniform shader parameter
  7895. * @param negativeUniform The negative uniform shader parameter
  7896. */
  7897. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7898. /**
  7899. * Prepare the list of uniforms associated with the ColorCurves effects.
  7900. * @param uniformsList The list of uniforms used in the effect
  7901. */
  7902. static PrepareUniforms(uniformsList: string[]): void;
  7903. /**
  7904. * Returns color grading data based on a hue, density, saturation and exposure value.
  7905. * @param filterHue The hue of the color filter.
  7906. * @param filterDensity The density of the color filter.
  7907. * @param saturation The saturation.
  7908. * @param exposure The exposure.
  7909. * @param result The result data container.
  7910. */
  7911. private getColorGradingDataToRef;
  7912. /**
  7913. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7914. * @param value The input slider value in range [-100,100].
  7915. * @returns Adjusted value.
  7916. */
  7917. private static applyColorGradingSliderNonlinear;
  7918. /**
  7919. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7920. * @param hue The hue (H) input.
  7921. * @param saturation The saturation (S) input.
  7922. * @param brightness The brightness (B) input.
  7923. * @result An RGBA color represented as Vector4.
  7924. */
  7925. private static fromHSBToRef;
  7926. /**
  7927. * Returns a value clamped between min and max
  7928. * @param value The value to clamp
  7929. * @param min The minimum of value
  7930. * @param max The maximum of value
  7931. * @returns The clamped value.
  7932. */
  7933. private static clamp;
  7934. /**
  7935. * Clones the current color curve instance.
  7936. * @return The cloned curves
  7937. */
  7938. clone(): ColorCurves;
  7939. /**
  7940. * Serializes the current color curve instance to a json representation.
  7941. * @return a JSON representation
  7942. */
  7943. serialize(): any;
  7944. /**
  7945. * Parses the color curve from a json representation.
  7946. * @param source the JSON source to parse
  7947. * @return The parsed curves
  7948. */
  7949. static Parse(source: any): ColorCurves;
  7950. }
  7951. }
  7952. declare module BABYLON {
  7953. /**
  7954. * Interface to follow in your material defines to integrate easily the
  7955. * Image proccessing functions.
  7956. * @hidden
  7957. */
  7958. export interface IImageProcessingConfigurationDefines {
  7959. IMAGEPROCESSING: boolean;
  7960. VIGNETTE: boolean;
  7961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7962. VIGNETTEBLENDMODEOPAQUE: boolean;
  7963. TONEMAPPING: boolean;
  7964. TONEMAPPING_ACES: boolean;
  7965. CONTRAST: boolean;
  7966. EXPOSURE: boolean;
  7967. COLORCURVES: boolean;
  7968. COLORGRADING: boolean;
  7969. COLORGRADING3D: boolean;
  7970. SAMPLER3DGREENDEPTH: boolean;
  7971. SAMPLER3DBGRMAP: boolean;
  7972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7973. }
  7974. /**
  7975. * @hidden
  7976. */
  7977. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7978. IMAGEPROCESSING: boolean;
  7979. VIGNETTE: boolean;
  7980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7981. VIGNETTEBLENDMODEOPAQUE: boolean;
  7982. TONEMAPPING: boolean;
  7983. TONEMAPPING_ACES: boolean;
  7984. CONTRAST: boolean;
  7985. COLORCURVES: boolean;
  7986. COLORGRADING: boolean;
  7987. COLORGRADING3D: boolean;
  7988. SAMPLER3DGREENDEPTH: boolean;
  7989. SAMPLER3DBGRMAP: boolean;
  7990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7991. EXPOSURE: boolean;
  7992. constructor();
  7993. }
  7994. /**
  7995. * This groups together the common properties used for image processing either in direct forward pass
  7996. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7997. * or not.
  7998. */
  7999. export class ImageProcessingConfiguration {
  8000. /**
  8001. * Default tone mapping applied in BabylonJS.
  8002. */
  8003. static readonly TONEMAPPING_STANDARD: number;
  8004. /**
  8005. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8006. * to other engines rendering to increase portability.
  8007. */
  8008. static readonly TONEMAPPING_ACES: number;
  8009. /**
  8010. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8011. */
  8012. colorCurves: Nullable<ColorCurves>;
  8013. private _colorCurvesEnabled;
  8014. /**
  8015. * Gets wether the color curves effect is enabled.
  8016. */
  8017. /**
  8018. * Sets wether the color curves effect is enabled.
  8019. */
  8020. colorCurvesEnabled: boolean;
  8021. private _colorGradingTexture;
  8022. /**
  8023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8024. */
  8025. /**
  8026. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8027. */
  8028. colorGradingTexture: Nullable<BaseTexture>;
  8029. private _colorGradingEnabled;
  8030. /**
  8031. * Gets wether the color grading effect is enabled.
  8032. */
  8033. /**
  8034. * Sets wether the color grading effect is enabled.
  8035. */
  8036. colorGradingEnabled: boolean;
  8037. private _colorGradingWithGreenDepth;
  8038. /**
  8039. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8040. */
  8041. /**
  8042. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8043. */
  8044. colorGradingWithGreenDepth: boolean;
  8045. private _colorGradingBGR;
  8046. /**
  8047. * Gets wether the color grading texture contains BGR values.
  8048. */
  8049. /**
  8050. * Sets wether the color grading texture contains BGR values.
  8051. */
  8052. colorGradingBGR: boolean;
  8053. /** @hidden */
  8054. _exposure: number;
  8055. /**
  8056. * Gets the Exposure used in the effect.
  8057. */
  8058. /**
  8059. * Sets the Exposure used in the effect.
  8060. */
  8061. exposure: number;
  8062. private _toneMappingEnabled;
  8063. /**
  8064. * Gets wether the tone mapping effect is enabled.
  8065. */
  8066. /**
  8067. * Sets wether the tone mapping effect is enabled.
  8068. */
  8069. toneMappingEnabled: boolean;
  8070. private _toneMappingType;
  8071. /**
  8072. * Gets the type of tone mapping effect.
  8073. */
  8074. /**
  8075. * Sets the type of tone mapping effect used in BabylonJS.
  8076. */
  8077. toneMappingType: number;
  8078. protected _contrast: number;
  8079. /**
  8080. * Gets the contrast used in the effect.
  8081. */
  8082. /**
  8083. * Sets the contrast used in the effect.
  8084. */
  8085. contrast: number;
  8086. /**
  8087. * Vignette stretch size.
  8088. */
  8089. vignetteStretch: number;
  8090. /**
  8091. * Vignette centre X Offset.
  8092. */
  8093. vignetteCentreX: number;
  8094. /**
  8095. * Vignette centre Y Offset.
  8096. */
  8097. vignetteCentreY: number;
  8098. /**
  8099. * Vignette weight or intensity of the vignette effect.
  8100. */
  8101. vignetteWeight: number;
  8102. /**
  8103. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8104. * if vignetteEnabled is set to true.
  8105. */
  8106. vignetteColor: Color4;
  8107. /**
  8108. * Camera field of view used by the Vignette effect.
  8109. */
  8110. vignetteCameraFov: number;
  8111. private _vignetteBlendMode;
  8112. /**
  8113. * Gets the vignette blend mode allowing different kind of effect.
  8114. */
  8115. /**
  8116. * Sets the vignette blend mode allowing different kind of effect.
  8117. */
  8118. vignetteBlendMode: number;
  8119. private _vignetteEnabled;
  8120. /**
  8121. * Gets wether the vignette effect is enabled.
  8122. */
  8123. /**
  8124. * Sets wether the vignette effect is enabled.
  8125. */
  8126. vignetteEnabled: boolean;
  8127. private _applyByPostProcess;
  8128. /**
  8129. * Gets wether the image processing is applied through a post process or not.
  8130. */
  8131. /**
  8132. * Sets wether the image processing is applied through a post process or not.
  8133. */
  8134. applyByPostProcess: boolean;
  8135. private _isEnabled;
  8136. /**
  8137. * Gets wether the image processing is enabled or not.
  8138. */
  8139. /**
  8140. * Sets wether the image processing is enabled or not.
  8141. */
  8142. isEnabled: boolean;
  8143. /**
  8144. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8145. */
  8146. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8147. /**
  8148. * Method called each time the image processing information changes requires to recompile the effect.
  8149. */
  8150. protected _updateParameters(): void;
  8151. /**
  8152. * Gets the current class name.
  8153. * @return "ImageProcessingConfiguration"
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Prepare the list of uniforms associated with the Image Processing effects.
  8158. * @param uniforms The list of uniforms used in the effect
  8159. * @param defines the list of defines currently in use
  8160. */
  8161. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8162. /**
  8163. * Prepare the list of samplers associated with the Image Processing effects.
  8164. * @param samplersList The list of uniforms used in the effect
  8165. * @param defines the list of defines currently in use
  8166. */
  8167. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8168. /**
  8169. * Prepare the list of defines associated to the shader.
  8170. * @param defines the list of defines to complete
  8171. * @param forPostProcess Define if we are currently in post process mode or not
  8172. */
  8173. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8174. /**
  8175. * Returns true if all the image processing information are ready.
  8176. * @returns True if ready, otherwise, false
  8177. */
  8178. isReady(): boolean;
  8179. /**
  8180. * Binds the image processing to the shader.
  8181. * @param effect The effect to bind to
  8182. * @param aspectRatio Define the current aspect ratio of the effect
  8183. */
  8184. bind(effect: Effect, aspectRatio?: number): void;
  8185. /**
  8186. * Clones the current image processing instance.
  8187. * @return The cloned image processing
  8188. */
  8189. clone(): ImageProcessingConfiguration;
  8190. /**
  8191. * Serializes the current image processing instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the image processing from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed image processing
  8199. */
  8200. static Parse(source: any): ImageProcessingConfiguration;
  8201. private static _VIGNETTEMODE_MULTIPLY;
  8202. private static _VIGNETTEMODE_OPAQUE;
  8203. /**
  8204. * Used to apply the vignette as a mix with the pixel color.
  8205. */
  8206. static readonly VIGNETTEMODE_MULTIPLY: number;
  8207. /**
  8208. * Used to apply the vignette as a replacement of the pixel color.
  8209. */
  8210. static readonly VIGNETTEMODE_OPAQUE: number;
  8211. }
  8212. }
  8213. declare module BABYLON {
  8214. /** @hidden */
  8215. export var postprocessVertexShader: {
  8216. name: string;
  8217. shader: string;
  8218. };
  8219. }
  8220. declare module BABYLON {
  8221. /** Defines supported spaces */
  8222. export enum Space {
  8223. /** Local (object) space */
  8224. LOCAL = 0,
  8225. /** World space */
  8226. WORLD = 1,
  8227. /** Bone space */
  8228. BONE = 2
  8229. }
  8230. /** Defines the 3 main axes */
  8231. export class Axis {
  8232. /** X axis */
  8233. static X: Vector3;
  8234. /** Y axis */
  8235. static Y: Vector3;
  8236. /** Z axis */
  8237. static Z: Vector3;
  8238. }
  8239. }
  8240. declare module BABYLON {
  8241. /**
  8242. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8243. * This is the base of the follow, arc rotate cameras and Free camera
  8244. * @see http://doc.babylonjs.com/features/cameras
  8245. */
  8246. export class TargetCamera extends Camera {
  8247. private static _RigCamTransformMatrix;
  8248. private static _TargetTransformMatrix;
  8249. private static _TargetFocalPoint;
  8250. /**
  8251. * Define the current direction the camera is moving to
  8252. */
  8253. cameraDirection: Vector3;
  8254. /**
  8255. * Define the current rotation the camera is rotating to
  8256. */
  8257. cameraRotation: Vector2;
  8258. /**
  8259. * When set, the up vector of the camera will be updated by the rotation of the camera
  8260. */
  8261. updateUpVectorFromRotation: boolean;
  8262. private _tmpQuaternion;
  8263. /**
  8264. * Define the current rotation of the camera
  8265. */
  8266. rotation: Vector3;
  8267. /**
  8268. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8269. */
  8270. rotationQuaternion: Quaternion;
  8271. /**
  8272. * Define the current speed of the camera
  8273. */
  8274. speed: number;
  8275. /**
  8276. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8277. * around all axis.
  8278. */
  8279. noRotationConstraint: boolean;
  8280. /**
  8281. * Define the current target of the camera as an object or a position.
  8282. */
  8283. lockedTarget: any;
  8284. /** @hidden */
  8285. _currentTarget: Vector3;
  8286. /** @hidden */
  8287. _initialFocalDistance: number;
  8288. /** @hidden */
  8289. _viewMatrix: Matrix;
  8290. /** @hidden */
  8291. _camMatrix: Matrix;
  8292. /** @hidden */
  8293. _cameraTransformMatrix: Matrix;
  8294. /** @hidden */
  8295. _cameraRotationMatrix: Matrix;
  8296. /** @hidden */
  8297. _referencePoint: Vector3;
  8298. /** @hidden */
  8299. _transformedReferencePoint: Vector3;
  8300. protected _globalCurrentTarget: Vector3;
  8301. protected _globalCurrentUpVector: Vector3;
  8302. /** @hidden */
  8303. _reset: () => void;
  8304. private _defaultUp;
  8305. /**
  8306. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8307. * This is the base of the follow, arc rotate cameras and Free camera
  8308. * @see http://doc.babylonjs.com/features/cameras
  8309. * @param name Defines the name of the camera in the scene
  8310. * @param position Defines the start position of the camera in the scene
  8311. * @param scene Defines the scene the camera belongs to
  8312. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8313. */
  8314. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8315. /**
  8316. * Gets the position in front of the camera at a given distance.
  8317. * @param distance The distance from the camera we want the position to be
  8318. * @returns the position
  8319. */
  8320. getFrontPosition(distance: number): Vector3;
  8321. /** @hidden */
  8322. _getLockedTargetPosition(): Nullable<Vector3>;
  8323. private _storedPosition;
  8324. private _storedRotation;
  8325. private _storedRotationQuaternion;
  8326. /**
  8327. * Store current camera state of the camera (fov, position, rotation, etc..)
  8328. * @returns the camera
  8329. */
  8330. storeState(): Camera;
  8331. /**
  8332. * Restored camera state. You must call storeState() first
  8333. * @returns whether it was successful or not
  8334. * @hidden
  8335. */
  8336. _restoreStateValues(): boolean;
  8337. /** @hidden */
  8338. _initCache(): void;
  8339. /** @hidden */
  8340. _updateCache(ignoreParentClass?: boolean): void;
  8341. /** @hidden */
  8342. _isSynchronizedViewMatrix(): boolean;
  8343. /** @hidden */
  8344. _computeLocalCameraSpeed(): number;
  8345. /**
  8346. * Defines the target the camera should look at.
  8347. * @param target Defines the new target as a Vector or a mesh
  8348. */
  8349. setTarget(target: Vector3): void;
  8350. /**
  8351. * Return the current target position of the camera. This value is expressed in local space.
  8352. * @returns the target position
  8353. */
  8354. getTarget(): Vector3;
  8355. /** @hidden */
  8356. _decideIfNeedsToMove(): boolean;
  8357. /** @hidden */
  8358. _updatePosition(): void;
  8359. /** @hidden */
  8360. _checkInputs(): void;
  8361. protected _updateCameraRotationMatrix(): void;
  8362. /**
  8363. * 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)
  8364. * @returns the current camera
  8365. */
  8366. private _rotateUpVectorWithCameraRotationMatrix;
  8367. private _cachedRotationZ;
  8368. private _cachedQuaternionRotationZ;
  8369. /** @hidden */
  8370. _getViewMatrix(): Matrix;
  8371. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8372. /**
  8373. * @hidden
  8374. */
  8375. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8376. /**
  8377. * @hidden
  8378. */
  8379. _updateRigCameras(): void;
  8380. private _getRigCamPositionAndTarget;
  8381. /**
  8382. * Gets the current object class name.
  8383. * @return the class name
  8384. */
  8385. getClassName(): string;
  8386. }
  8387. }
  8388. declare module BABYLON {
  8389. /**
  8390. * Gather the list of keyboard event types as constants.
  8391. */
  8392. export class KeyboardEventTypes {
  8393. /**
  8394. * The keydown event is fired when a key becomes active (pressed).
  8395. */
  8396. static readonly KEYDOWN: number;
  8397. /**
  8398. * The keyup event is fired when a key has been released.
  8399. */
  8400. static readonly KEYUP: number;
  8401. }
  8402. /**
  8403. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8404. */
  8405. export class KeyboardInfo {
  8406. /**
  8407. * Defines the type of event (KeyboardEventTypes)
  8408. */
  8409. type: number;
  8410. /**
  8411. * Defines the related dom event
  8412. */
  8413. event: KeyboardEvent;
  8414. /**
  8415. * Instantiates a new keyboard info.
  8416. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8417. * @param type Defines the type of event (KeyboardEventTypes)
  8418. * @param event Defines the related dom event
  8419. */
  8420. constructor(
  8421. /**
  8422. * Defines the type of event (KeyboardEventTypes)
  8423. */
  8424. type: number,
  8425. /**
  8426. * Defines the related dom event
  8427. */
  8428. event: KeyboardEvent);
  8429. }
  8430. /**
  8431. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8432. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8433. */
  8434. export class KeyboardInfoPre extends KeyboardInfo {
  8435. /**
  8436. * Defines the type of event (KeyboardEventTypes)
  8437. */
  8438. type: number;
  8439. /**
  8440. * Defines the related dom event
  8441. */
  8442. event: KeyboardEvent;
  8443. /**
  8444. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8445. */
  8446. skipOnPointerObservable: boolean;
  8447. /**
  8448. * Instantiates a new keyboard pre info.
  8449. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8450. * @param type Defines the type of event (KeyboardEventTypes)
  8451. * @param event Defines the related dom event
  8452. */
  8453. constructor(
  8454. /**
  8455. * Defines the type of event (KeyboardEventTypes)
  8456. */
  8457. type: number,
  8458. /**
  8459. * Defines the related dom event
  8460. */
  8461. event: KeyboardEvent);
  8462. }
  8463. }
  8464. declare module BABYLON {
  8465. /**
  8466. * Manage the keyboard inputs to control the movement of a free camera.
  8467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8468. */
  8469. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8470. /**
  8471. * Defines the camera the input is attached to.
  8472. */
  8473. camera: FreeCamera;
  8474. /**
  8475. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8476. */
  8477. keysUp: number[];
  8478. /**
  8479. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8480. */
  8481. keysDown: number[];
  8482. /**
  8483. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8484. */
  8485. keysLeft: number[];
  8486. /**
  8487. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8488. */
  8489. keysRight: number[];
  8490. private _keys;
  8491. private _onCanvasBlurObserver;
  8492. private _onKeyboardObserver;
  8493. private _engine;
  8494. private _scene;
  8495. /**
  8496. * Attach the input controls to a specific dom element to get the input from.
  8497. * @param element Defines the element the controls should be listened from
  8498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8499. */
  8500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8501. /**
  8502. * Detach the current controls from the specified dom element.
  8503. * @param element Defines the element to stop listening the inputs from
  8504. */
  8505. detachControl(element: Nullable<HTMLElement>): void;
  8506. /**
  8507. * Update the current camera state depending on the inputs that have been used this frame.
  8508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8509. */
  8510. checkInputs(): void;
  8511. /**
  8512. * Gets the class name of the current intput.
  8513. * @returns the class name
  8514. */
  8515. getClassName(): string;
  8516. /** @hidden */
  8517. _onLostFocus(): void;
  8518. /**
  8519. * Get the friendly name associated with the input class.
  8520. * @returns the input friendly name
  8521. */
  8522. getSimpleName(): string;
  8523. }
  8524. }
  8525. declare module BABYLON {
  8526. /**
  8527. * Interface describing all the common properties and methods a shadow light needs to implement.
  8528. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8529. * as well as binding the different shadow properties to the effects.
  8530. */
  8531. export interface IShadowLight extends Light {
  8532. /**
  8533. * The light id in the scene (used in scene.findLighById for instance)
  8534. */
  8535. id: string;
  8536. /**
  8537. * The position the shdow will be casted from.
  8538. */
  8539. position: Vector3;
  8540. /**
  8541. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8542. */
  8543. direction: Vector3;
  8544. /**
  8545. * The transformed position. Position of the light in world space taking parenting in account.
  8546. */
  8547. transformedPosition: Vector3;
  8548. /**
  8549. * The transformed direction. Direction of the light in world space taking parenting in account.
  8550. */
  8551. transformedDirection: Vector3;
  8552. /**
  8553. * The friendly name of the light in the scene.
  8554. */
  8555. name: string;
  8556. /**
  8557. * Defines the shadow projection clipping minimum z value.
  8558. */
  8559. shadowMinZ: number;
  8560. /**
  8561. * Defines the shadow projection clipping maximum z value.
  8562. */
  8563. shadowMaxZ: number;
  8564. /**
  8565. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8566. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8567. */
  8568. computeTransformedInformation(): boolean;
  8569. /**
  8570. * Gets the scene the light belongs to.
  8571. * @returns The scene
  8572. */
  8573. getScene(): Scene;
  8574. /**
  8575. * Callback defining a custom Projection Matrix Builder.
  8576. * This can be used to override the default projection matrix computation.
  8577. */
  8578. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8579. /**
  8580. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8581. * @param matrix The materix to updated with the projection information
  8582. * @param viewMatrix The transform matrix of the light
  8583. * @param renderList The list of mesh to render in the map
  8584. * @returns The current light
  8585. */
  8586. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8587. /**
  8588. * Gets the current depth scale used in ESM.
  8589. * @returns The scale
  8590. */
  8591. getDepthScale(): number;
  8592. /**
  8593. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8594. * @returns true if a cube texture needs to be use
  8595. */
  8596. needCube(): boolean;
  8597. /**
  8598. * Detects if the projection matrix requires to be recomputed this frame.
  8599. * @returns true if it requires to be recomputed otherwise, false.
  8600. */
  8601. needProjectionMatrixCompute(): boolean;
  8602. /**
  8603. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8604. */
  8605. forceProjectionMatrixCompute(): void;
  8606. /**
  8607. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8608. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8609. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8610. */
  8611. getShadowDirection(faceIndex?: number): Vector3;
  8612. /**
  8613. * Gets the minZ used for shadow according to both the scene and the light.
  8614. * @param activeCamera The camera we are returning the min for
  8615. * @returns the depth min z
  8616. */
  8617. getDepthMinZ(activeCamera: Camera): number;
  8618. /**
  8619. * Gets the maxZ used for shadow according to both the scene and the light.
  8620. * @param activeCamera The camera we are returning the max for
  8621. * @returns the depth max z
  8622. */
  8623. getDepthMaxZ(activeCamera: Camera): number;
  8624. }
  8625. /**
  8626. * Base implementation IShadowLight
  8627. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8628. */
  8629. export abstract class ShadowLight extends Light implements IShadowLight {
  8630. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8631. protected _position: Vector3;
  8632. protected _setPosition(value: Vector3): void;
  8633. /**
  8634. * Sets the position the shadow will be casted from. Also use as the light position for both
  8635. * point and spot lights.
  8636. */
  8637. /**
  8638. * Sets the position the shadow will be casted from. Also use as the light position for both
  8639. * point and spot lights.
  8640. */
  8641. position: Vector3;
  8642. protected _direction: Vector3;
  8643. protected _setDirection(value: Vector3): void;
  8644. /**
  8645. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8646. * Also use as the light direction on spot and directional lights.
  8647. */
  8648. /**
  8649. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8650. * Also use as the light direction on spot and directional lights.
  8651. */
  8652. direction: Vector3;
  8653. private _shadowMinZ;
  8654. /**
  8655. * Gets the shadow projection clipping minimum z value.
  8656. */
  8657. /**
  8658. * Sets the shadow projection clipping minimum z value.
  8659. */
  8660. shadowMinZ: number;
  8661. private _shadowMaxZ;
  8662. /**
  8663. * Sets the shadow projection clipping maximum z value.
  8664. */
  8665. /**
  8666. * Gets the shadow projection clipping maximum z value.
  8667. */
  8668. shadowMaxZ: number;
  8669. /**
  8670. * Callback defining a custom Projection Matrix Builder.
  8671. * This can be used to override the default projection matrix computation.
  8672. */
  8673. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8674. /**
  8675. * The transformed position. Position of the light in world space taking parenting in account.
  8676. */
  8677. transformedPosition: Vector3;
  8678. /**
  8679. * The transformed direction. Direction of the light in world space taking parenting in account.
  8680. */
  8681. transformedDirection: Vector3;
  8682. private _needProjectionMatrixCompute;
  8683. /**
  8684. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8685. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8686. */
  8687. computeTransformedInformation(): boolean;
  8688. /**
  8689. * Return the depth scale used for the shadow map.
  8690. * @returns the depth scale.
  8691. */
  8692. getDepthScale(): number;
  8693. /**
  8694. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8695. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8696. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8697. */
  8698. getShadowDirection(faceIndex?: number): Vector3;
  8699. /**
  8700. * Returns the ShadowLight absolute position in the World.
  8701. * @returns the position vector in world space
  8702. */
  8703. getAbsolutePosition(): Vector3;
  8704. /**
  8705. * Sets the ShadowLight direction toward the passed target.
  8706. * @param target The point to target in local space
  8707. * @returns the updated ShadowLight direction
  8708. */
  8709. setDirectionToTarget(target: Vector3): Vector3;
  8710. /**
  8711. * Returns the light rotation in euler definition.
  8712. * @returns the x y z rotation in local space.
  8713. */
  8714. getRotation(): Vector3;
  8715. /**
  8716. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8717. * @returns true if a cube texture needs to be use
  8718. */
  8719. needCube(): boolean;
  8720. /**
  8721. * Detects if the projection matrix requires to be recomputed this frame.
  8722. * @returns true if it requires to be recomputed otherwise, false.
  8723. */
  8724. needProjectionMatrixCompute(): boolean;
  8725. /**
  8726. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8727. */
  8728. forceProjectionMatrixCompute(): void;
  8729. /** @hidden */
  8730. _initCache(): void;
  8731. /** @hidden */
  8732. _isSynchronized(): boolean;
  8733. /**
  8734. * Computes the world matrix of the node
  8735. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8736. * @returns the world matrix
  8737. */
  8738. computeWorldMatrix(force?: boolean): Matrix;
  8739. /**
  8740. * Gets the minZ used for shadow according to both the scene and the light.
  8741. * @param activeCamera The camera we are returning the min for
  8742. * @returns the depth min z
  8743. */
  8744. getDepthMinZ(activeCamera: Camera): number;
  8745. /**
  8746. * Gets the maxZ used for shadow according to both the scene and the light.
  8747. * @param activeCamera The camera we are returning the max for
  8748. * @returns the depth max z
  8749. */
  8750. getDepthMaxZ(activeCamera: Camera): number;
  8751. /**
  8752. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8753. * @param matrix The materix to updated with the projection information
  8754. * @param viewMatrix The transform matrix of the light
  8755. * @param renderList The list of mesh to render in the map
  8756. * @returns The current light
  8757. */
  8758. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8759. }
  8760. }
  8761. declare module BABYLON {
  8762. /**
  8763. * "Static Class" containing the most commonly used helper while dealing with material for
  8764. * rendering purpose.
  8765. *
  8766. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8767. *
  8768. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8769. */
  8770. export class MaterialHelper {
  8771. /**
  8772. * Bind the current view position to an effect.
  8773. * @param effect The effect to be bound
  8774. * @param scene The scene the eyes position is used from
  8775. */
  8776. static BindEyePosition(effect: Effect, scene: Scene): void;
  8777. /**
  8778. * Helps preparing the defines values about the UVs in used in the effect.
  8779. * UVs are shared as much as we can accross channels in the shaders.
  8780. * @param texture The texture we are preparing the UVs for
  8781. * @param defines The defines to update
  8782. * @param key The channel key "diffuse", "specular"... used in the shader
  8783. */
  8784. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8785. /**
  8786. * Binds a texture matrix value to its corrsponding uniform
  8787. * @param texture The texture to bind the matrix for
  8788. * @param uniformBuffer The uniform buffer receivin the data
  8789. * @param key The channel key "diffuse", "specular"... used in the shader
  8790. */
  8791. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8792. /**
  8793. * Gets the current status of the fog (should it be enabled?)
  8794. * @param mesh defines the mesh to evaluate for fog support
  8795. * @param scene defines the hosting scene
  8796. * @returns true if fog must be enabled
  8797. */
  8798. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8799. /**
  8800. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8801. * @param mesh defines the current mesh
  8802. * @param scene defines the current scene
  8803. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8804. * @param pointsCloud defines if point cloud rendering has to be turned on
  8805. * @param fogEnabled defines if fog has to be turned on
  8806. * @param alphaTest defines if alpha testing has to be turned on
  8807. * @param defines defines the current list of defines
  8808. */
  8809. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8810. /**
  8811. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8812. * @param scene defines the current scene
  8813. * @param engine defines the current engine
  8814. * @param defines specifies the list of active defines
  8815. * @param useInstances defines if instances have to be turned on
  8816. * @param useClipPlane defines if clip plane have to be turned on
  8817. */
  8818. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8819. /**
  8820. * Prepares the defines for bones
  8821. * @param mesh The mesh containing the geometry data we will draw
  8822. * @param defines The defines to update
  8823. */
  8824. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8825. /**
  8826. * Prepares the defines for morph targets
  8827. * @param mesh The mesh containing the geometry data we will draw
  8828. * @param defines The defines to update
  8829. */
  8830. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8831. /**
  8832. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8833. * @param mesh The mesh containing the geometry data we will draw
  8834. * @param defines The defines to update
  8835. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8836. * @param useBones Precise whether bones should be used or not (override mesh info)
  8837. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8838. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8839. * @returns false if defines are considered not dirty and have not been checked
  8840. */
  8841. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8842. /**
  8843. * Prepares the defines related to multiview
  8844. * @param scene The scene we are intending to draw
  8845. * @param defines The defines to update
  8846. */
  8847. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8848. /**
  8849. * Prepares the defines related to the light information passed in parameter
  8850. * @param scene The scene we are intending to draw
  8851. * @param mesh The mesh the effect is compiling for
  8852. * @param light The light the effect is compiling for
  8853. * @param lightIndex The index of the light
  8854. * @param defines The defines to update
  8855. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8856. * @param state Defines the current state regarding what is needed (normals, etc...)
  8857. */
  8858. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8859. needNormals: boolean;
  8860. needRebuild: boolean;
  8861. shadowEnabled: boolean;
  8862. specularEnabled: boolean;
  8863. lightmapMode: boolean;
  8864. }): void;
  8865. /**
  8866. * Prepares the defines related to the light information passed in parameter
  8867. * @param scene The scene we are intending to draw
  8868. * @param mesh The mesh the effect is compiling for
  8869. * @param defines The defines to update
  8870. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8871. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8872. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8873. * @returns true if normals will be required for the rest of the effect
  8874. */
  8875. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8876. /**
  8877. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8878. * @param lightIndex defines the light index
  8879. * @param uniformsList The uniform list
  8880. * @param samplersList The sampler list
  8881. * @param projectedLightTexture defines if projected texture must be used
  8882. * @param uniformBuffersList defines an optional list of uniform buffers
  8883. */
  8884. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8885. /**
  8886. * Prepares the uniforms and samplers list to be used in the effect
  8887. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8888. * @param samplersList The sampler list
  8889. * @param defines The defines helping in the list generation
  8890. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8891. */
  8892. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8893. /**
  8894. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8895. * @param defines The defines to update while falling back
  8896. * @param fallbacks The authorized effect fallbacks
  8897. * @param maxSimultaneousLights The maximum number of lights allowed
  8898. * @param rank the current rank of the Effect
  8899. * @returns The newly affected rank
  8900. */
  8901. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8902. private static _TmpMorphInfluencers;
  8903. /**
  8904. * Prepares the list of attributes required for morph targets according to the effect defines.
  8905. * @param attribs The current list of supported attribs
  8906. * @param mesh The mesh to prepare the morph targets attributes for
  8907. * @param influencers The number of influencers
  8908. */
  8909. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8910. /**
  8911. * Prepares the list of attributes required for morph targets according to the effect defines.
  8912. * @param attribs The current list of supported attribs
  8913. * @param mesh The mesh to prepare the morph targets attributes for
  8914. * @param defines The current Defines of the effect
  8915. */
  8916. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8917. /**
  8918. * Prepares the list of attributes required for bones according to the effect defines.
  8919. * @param attribs The current list of supported attribs
  8920. * @param mesh The mesh to prepare the bones attributes for
  8921. * @param defines The current Defines of the effect
  8922. * @param fallbacks The current efffect fallback strategy
  8923. */
  8924. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8925. /**
  8926. * Check and prepare the list of attributes required for instances according to the effect defines.
  8927. * @param attribs The current list of supported attribs
  8928. * @param defines The current MaterialDefines of the effect
  8929. */
  8930. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8931. /**
  8932. * Add the list of attributes required for instances to the attribs array.
  8933. * @param attribs The current list of supported attribs
  8934. */
  8935. static PushAttributesForInstances(attribs: string[]): void;
  8936. /**
  8937. * Binds the light shadow information to the effect for the given mesh.
  8938. * @param light The light containing the generator
  8939. * @param scene The scene the lights belongs to
  8940. * @param mesh The mesh we are binding the information to render
  8941. * @param lightIndex The light index in the effect used to render the mesh
  8942. * @param effect The effect we are binding the data to
  8943. */
  8944. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8945. /**
  8946. * Binds the light information to the effect.
  8947. * @param light The light containing the generator
  8948. * @param effect The effect we are binding the data to
  8949. * @param lightIndex The light index in the effect used to render
  8950. */
  8951. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8952. /**
  8953. * Binds the lights information from the scene to the effect for the given mesh.
  8954. * @param light Light to bind
  8955. * @param lightIndex Light index
  8956. * @param scene The scene where the light belongs to
  8957. * @param mesh The mesh we are binding the information to render
  8958. * @param effect The effect we are binding the data to
  8959. * @param useSpecular Defines if specular is supported
  8960. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8961. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8962. */
  8963. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8964. /**
  8965. * Binds the lights information from the scene to the effect for the given mesh.
  8966. * @param scene The scene the lights belongs to
  8967. * @param mesh The mesh we are binding the information to render
  8968. * @param effect The effect we are binding the data to
  8969. * @param defines The generated defines for the effect
  8970. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8971. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8972. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8973. */
  8974. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8975. private static _tempFogColor;
  8976. /**
  8977. * Binds the fog information from the scene to the effect for the given mesh.
  8978. * @param scene The scene the lights belongs to
  8979. * @param mesh The mesh we are binding the information to render
  8980. * @param effect The effect we are binding the data to
  8981. * @param linearSpace Defines if the fog effect is applied in linear space
  8982. */
  8983. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8984. /**
  8985. * Binds the bones information from the mesh to the effect.
  8986. * @param mesh The mesh we are binding the information to render
  8987. * @param effect The effect we are binding the data to
  8988. */
  8989. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8990. /**
  8991. * Binds the morph targets information from the mesh to the effect.
  8992. * @param abstractMesh The mesh we are binding the information to render
  8993. * @param effect The effect we are binding the data to
  8994. */
  8995. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8996. /**
  8997. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8998. * @param defines The generated defines used in the effect
  8999. * @param effect The effect we are binding the data to
  9000. * @param scene The scene we are willing to render with logarithmic scale for
  9001. */
  9002. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9003. /**
  9004. * Binds the clip plane information from the scene to the effect.
  9005. * @param scene The scene the clip plane information are extracted from
  9006. * @param effect The effect we are binding the data to
  9007. */
  9008. static BindClipPlane(effect: Effect, scene: Scene): void;
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /** @hidden */
  9013. export var packingFunctions: {
  9014. name: string;
  9015. shader: string;
  9016. };
  9017. }
  9018. declare module BABYLON {
  9019. /** @hidden */
  9020. export var shadowMapPixelShader: {
  9021. name: string;
  9022. shader: string;
  9023. };
  9024. }
  9025. declare module BABYLON {
  9026. /** @hidden */
  9027. export var bonesDeclaration: {
  9028. name: string;
  9029. shader: string;
  9030. };
  9031. }
  9032. declare module BABYLON {
  9033. /** @hidden */
  9034. export var morphTargetsVertexGlobalDeclaration: {
  9035. name: string;
  9036. shader: string;
  9037. };
  9038. }
  9039. declare module BABYLON {
  9040. /** @hidden */
  9041. export var morphTargetsVertexDeclaration: {
  9042. name: string;
  9043. shader: string;
  9044. };
  9045. }
  9046. declare module BABYLON {
  9047. /** @hidden */
  9048. export var instancesDeclaration: {
  9049. name: string;
  9050. shader: string;
  9051. };
  9052. }
  9053. declare module BABYLON {
  9054. /** @hidden */
  9055. export var helperFunctions: {
  9056. name: string;
  9057. shader: string;
  9058. };
  9059. }
  9060. declare module BABYLON {
  9061. /** @hidden */
  9062. export var morphTargetsVertex: {
  9063. name: string;
  9064. shader: string;
  9065. };
  9066. }
  9067. declare module BABYLON {
  9068. /** @hidden */
  9069. export var instancesVertex: {
  9070. name: string;
  9071. shader: string;
  9072. };
  9073. }
  9074. declare module BABYLON {
  9075. /** @hidden */
  9076. export var bonesVertex: {
  9077. name: string;
  9078. shader: string;
  9079. };
  9080. }
  9081. declare module BABYLON {
  9082. /** @hidden */
  9083. export var shadowMapVertexShader: {
  9084. name: string;
  9085. shader: string;
  9086. };
  9087. }
  9088. declare module BABYLON {
  9089. /** @hidden */
  9090. export var depthBoxBlurPixelShader: {
  9091. name: string;
  9092. shader: string;
  9093. };
  9094. }
  9095. declare module BABYLON {
  9096. /**
  9097. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9098. */
  9099. export interface ICustomShaderOptions {
  9100. /**
  9101. * Gets or sets the custom shader name to use
  9102. */
  9103. shaderName: string;
  9104. /**
  9105. * The list of attribute names used in the shader
  9106. */
  9107. attributes?: string[];
  9108. /**
  9109. * The list of unifrom names used in the shader
  9110. */
  9111. uniforms?: string[];
  9112. /**
  9113. * The list of sampler names used in the shader
  9114. */
  9115. samplers?: string[];
  9116. /**
  9117. * The list of defines used in the shader
  9118. */
  9119. defines?: string[];
  9120. }
  9121. /**
  9122. * Interface to implement to create a shadow generator compatible with BJS.
  9123. */
  9124. export interface IShadowGenerator {
  9125. /**
  9126. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9127. * @returns The render target texture if present otherwise, null
  9128. */
  9129. getShadowMap(): Nullable<RenderTargetTexture>;
  9130. /**
  9131. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9132. * @returns The render target texture if the shadow map is present otherwise, null
  9133. */
  9134. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9137. * @param subMesh The submesh we want to render in the shadow map
  9138. * @param useInstances Defines wether will draw in the map using instances
  9139. * @returns true if ready otherwise, false
  9140. */
  9141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9142. /**
  9143. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9144. * @param defines Defines of the material we want to update
  9145. * @param lightIndex Index of the light in the enabled light list of the material
  9146. */
  9147. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9148. /**
  9149. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9150. * defined in the generator but impacting the effect).
  9151. * It implies the unifroms available on the materials are the standard BJS ones.
  9152. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9153. * @param effect The effect we are binfing the information for
  9154. */
  9155. bindShadowLight(lightIndex: string, effect: Effect): void;
  9156. /**
  9157. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9158. * (eq to shadow prjection matrix * light transform matrix)
  9159. * @returns The transform matrix used to create the shadow map
  9160. */
  9161. getTransformMatrix(): Matrix;
  9162. /**
  9163. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9164. * Cube and 2D textures for instance.
  9165. */
  9166. recreateShadowMap(): void;
  9167. /**
  9168. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9169. * @param onCompiled Callback triggered at the and of the effects compilation
  9170. * @param options Sets of optional options forcing the compilation with different modes
  9171. */
  9172. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9173. useInstances: boolean;
  9174. }>): void;
  9175. /**
  9176. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9177. * @param options Sets of optional options forcing the compilation with different modes
  9178. * @returns A promise that resolves when the compilation completes
  9179. */
  9180. forceCompilationAsync(options?: Partial<{
  9181. useInstances: boolean;
  9182. }>): Promise<void>;
  9183. /**
  9184. * Serializes the shadow generator setup to a json object.
  9185. * @returns The serialized JSON object
  9186. */
  9187. serialize(): any;
  9188. /**
  9189. * Disposes the Shadow map and related Textures and effects.
  9190. */
  9191. dispose(): void;
  9192. }
  9193. /**
  9194. * Default implementation IShadowGenerator.
  9195. * This is the main object responsible of generating shadows in the framework.
  9196. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9197. */
  9198. export class ShadowGenerator implements IShadowGenerator {
  9199. /**
  9200. * Shadow generator mode None: no filtering applied.
  9201. */
  9202. static readonly FILTER_NONE: number;
  9203. /**
  9204. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9206. */
  9207. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9208. /**
  9209. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9210. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9211. */
  9212. static readonly FILTER_POISSONSAMPLING: number;
  9213. /**
  9214. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9215. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9216. */
  9217. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9218. /**
  9219. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9220. * edge artifacts on steep falloff.
  9221. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9222. */
  9223. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9224. /**
  9225. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9226. * edge artifacts on steep falloff.
  9227. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9228. */
  9229. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9230. /**
  9231. * Shadow generator mode PCF: Percentage Closer Filtering
  9232. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9233. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9234. */
  9235. static readonly FILTER_PCF: number;
  9236. /**
  9237. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9238. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9239. * Contact Hardening
  9240. */
  9241. static readonly FILTER_PCSS: number;
  9242. /**
  9243. * Reserved for PCF and PCSS
  9244. * Highest Quality.
  9245. *
  9246. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9247. *
  9248. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9249. */
  9250. static readonly QUALITY_HIGH: number;
  9251. /**
  9252. * Reserved for PCF and PCSS
  9253. * Good tradeoff for quality/perf cross devices
  9254. *
  9255. * Execute PCF on a 3*3 kernel.
  9256. *
  9257. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9258. */
  9259. static readonly QUALITY_MEDIUM: number;
  9260. /**
  9261. * Reserved for PCF and PCSS
  9262. * The lowest quality but the fastest.
  9263. *
  9264. * Execute PCF on a 1*1 kernel.
  9265. *
  9266. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9267. */
  9268. static readonly QUALITY_LOW: number;
  9269. /** Gets or sets the custom shader name to use */
  9270. customShaderOptions: ICustomShaderOptions;
  9271. /**
  9272. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9273. */
  9274. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9275. /**
  9276. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9277. */
  9278. onAfterShadowMapRenderObservable: Observable<Effect>;
  9279. /**
  9280. * Observable triggered before a mesh is rendered in the shadow map.
  9281. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9282. */
  9283. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9284. /**
  9285. * Observable triggered after a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9287. */
  9288. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. private _bias;
  9290. /**
  9291. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9292. */
  9293. /**
  9294. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9295. */
  9296. bias: number;
  9297. private _normalBias;
  9298. /**
  9299. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9300. */
  9301. /**
  9302. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9303. */
  9304. normalBias: number;
  9305. private _blurBoxOffset;
  9306. /**
  9307. * Gets the blur box offset: offset applied during the blur pass.
  9308. * Only useful if useKernelBlur = false
  9309. */
  9310. /**
  9311. * Sets the blur box offset: offset applied during the blur pass.
  9312. * Only useful if useKernelBlur = false
  9313. */
  9314. blurBoxOffset: number;
  9315. private _blurScale;
  9316. /**
  9317. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9318. * 2 means half of the size.
  9319. */
  9320. /**
  9321. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9322. * 2 means half of the size.
  9323. */
  9324. blurScale: number;
  9325. private _blurKernel;
  9326. /**
  9327. * Gets the blur kernel: kernel size of the blur pass.
  9328. * Only useful if useKernelBlur = true
  9329. */
  9330. /**
  9331. * Sets the blur kernel: kernel size of the blur pass.
  9332. * Only useful if useKernelBlur = true
  9333. */
  9334. blurKernel: number;
  9335. private _useKernelBlur;
  9336. /**
  9337. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9338. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9339. */
  9340. /**
  9341. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9342. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9343. */
  9344. useKernelBlur: boolean;
  9345. private _depthScale;
  9346. /**
  9347. * Gets the depth scale used in ESM mode.
  9348. */
  9349. /**
  9350. * Sets the depth scale used in ESM mode.
  9351. * This can override the scale stored on the light.
  9352. */
  9353. depthScale: number;
  9354. private _filter;
  9355. /**
  9356. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9357. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9358. */
  9359. /**
  9360. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9361. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9362. */
  9363. filter: number;
  9364. /**
  9365. * Gets if the current filter is set to Poisson Sampling.
  9366. */
  9367. /**
  9368. * Sets the current filter to Poisson Sampling.
  9369. */
  9370. usePoissonSampling: boolean;
  9371. /**
  9372. * Gets if the current filter is set to ESM.
  9373. */
  9374. /**
  9375. * Sets the current filter is to ESM.
  9376. */
  9377. useExponentialShadowMap: boolean;
  9378. /**
  9379. * Gets if the current filter is set to filtered ESM.
  9380. */
  9381. /**
  9382. * Gets if the current filter is set to filtered ESM.
  9383. */
  9384. useBlurExponentialShadowMap: boolean;
  9385. /**
  9386. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9387. * exponential to prevent steep falloff artifacts).
  9388. */
  9389. /**
  9390. * Sets the current filter to "close ESM" (using the inverse of the
  9391. * exponential to prevent steep falloff artifacts).
  9392. */
  9393. useCloseExponentialShadowMap: boolean;
  9394. /**
  9395. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. /**
  9399. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9400. * exponential to prevent steep falloff artifacts).
  9401. */
  9402. useBlurCloseExponentialShadowMap: boolean;
  9403. /**
  9404. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9405. */
  9406. /**
  9407. * Sets the current filter to "PCF" (percentage closer filtering).
  9408. */
  9409. usePercentageCloserFiltering: boolean;
  9410. private _filteringQuality;
  9411. /**
  9412. * Gets the PCF or PCSS Quality.
  9413. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9414. */
  9415. /**
  9416. * Sets the PCF or PCSS Quality.
  9417. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9418. */
  9419. filteringQuality: number;
  9420. /**
  9421. * Gets if the current filter is set to "PCSS" (contact hardening).
  9422. */
  9423. /**
  9424. * Sets the current filter to "PCSS" (contact hardening).
  9425. */
  9426. useContactHardeningShadow: boolean;
  9427. private _contactHardeningLightSizeUVRatio;
  9428. /**
  9429. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9430. * Using a ratio helps keeping shape stability independently of the map size.
  9431. *
  9432. * It does not account for the light projection as it was having too much
  9433. * instability during the light setup or during light position changes.
  9434. *
  9435. * Only valid if useContactHardeningShadow is true.
  9436. */
  9437. /**
  9438. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9439. * Using a ratio helps keeping shape stability independently of the map size.
  9440. *
  9441. * It does not account for the light projection as it was having too much
  9442. * instability during the light setup or during light position changes.
  9443. *
  9444. * Only valid if useContactHardeningShadow is true.
  9445. */
  9446. contactHardeningLightSizeUVRatio: number;
  9447. private _darkness;
  9448. /** Gets or sets the actual darkness of a shadow */
  9449. darkness: number;
  9450. /**
  9451. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9452. * 0 means strongest and 1 would means no shadow.
  9453. * @returns the darkness.
  9454. */
  9455. getDarkness(): number;
  9456. /**
  9457. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9458. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9459. * @returns the shadow generator allowing fluent coding.
  9460. */
  9461. setDarkness(darkness: number): ShadowGenerator;
  9462. private _transparencyShadow;
  9463. /** Gets or sets the ability to have transparent shadow */
  9464. transparencyShadow: boolean;
  9465. /**
  9466. * Sets the ability to have transparent shadow (boolean).
  9467. * @param transparent True if transparent else False
  9468. * @returns the shadow generator allowing fluent coding
  9469. */
  9470. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9471. private _shadowMap;
  9472. private _shadowMap2;
  9473. /**
  9474. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9475. * @returns The render target texture if present otherwise, null
  9476. */
  9477. getShadowMap(): Nullable<RenderTargetTexture>;
  9478. /**
  9479. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9480. * @returns The render target texture if the shadow map is present otherwise, null
  9481. */
  9482. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the class name of that object
  9485. * @returns "ShadowGenerator"
  9486. */
  9487. getClassName(): string;
  9488. /**
  9489. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9490. * @param mesh Mesh to add
  9491. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9492. * @returns the Shadow Generator itself
  9493. */
  9494. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9495. /**
  9496. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9497. * @param mesh Mesh to remove
  9498. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9499. * @returns the Shadow Generator itself
  9500. */
  9501. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9502. /**
  9503. * Controls the extent to which the shadows fade out at the edge of the frustum
  9504. * Used only by directionals and spots
  9505. */
  9506. frustumEdgeFalloff: number;
  9507. private _light;
  9508. /**
  9509. * Returns the associated light object.
  9510. * @returns the light generating the shadow
  9511. */
  9512. getLight(): IShadowLight;
  9513. /**
  9514. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9515. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9516. * It might on the other hand introduce peter panning.
  9517. */
  9518. forceBackFacesOnly: boolean;
  9519. private _scene;
  9520. private _lightDirection;
  9521. private _effect;
  9522. private _viewMatrix;
  9523. private _projectionMatrix;
  9524. private _transformMatrix;
  9525. private _cachedPosition;
  9526. private _cachedDirection;
  9527. private _cachedDefines;
  9528. private _currentRenderID;
  9529. private _boxBlurPostprocess;
  9530. private _kernelBlurXPostprocess;
  9531. private _kernelBlurYPostprocess;
  9532. private _blurPostProcesses;
  9533. private _mapSize;
  9534. private _currentFaceIndex;
  9535. private _currentFaceIndexCache;
  9536. private _textureType;
  9537. private _defaultTextureMatrix;
  9538. /** @hidden */
  9539. static _SceneComponentInitialization: (scene: Scene) => void;
  9540. /**
  9541. * Creates a ShadowGenerator object.
  9542. * A ShadowGenerator is the required tool to use the shadows.
  9543. * Each light casting shadows needs to use its own ShadowGenerator.
  9544. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9545. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9546. * @param light The light object generating the shadows.
  9547. * @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.
  9548. */
  9549. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9550. private _initializeGenerator;
  9551. private _initializeShadowMap;
  9552. private _initializeBlurRTTAndPostProcesses;
  9553. private _renderForShadowMap;
  9554. private _renderSubMeshForShadowMap;
  9555. private _applyFilterValues;
  9556. /**
  9557. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9558. * @param onCompiled Callback triggered at the and of the effects compilation
  9559. * @param options Sets of optional options forcing the compilation with different modes
  9560. */
  9561. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9562. useInstances: boolean;
  9563. }>): void;
  9564. /**
  9565. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9566. * @param options Sets of optional options forcing the compilation with different modes
  9567. * @returns A promise that resolves when the compilation completes
  9568. */
  9569. forceCompilationAsync(options?: Partial<{
  9570. useInstances: boolean;
  9571. }>): Promise<void>;
  9572. /**
  9573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9574. * @param subMesh The submesh we want to render in the shadow map
  9575. * @param useInstances Defines wether will draw in the map using instances
  9576. * @returns true if ready otherwise, false
  9577. */
  9578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9579. /**
  9580. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9581. * @param defines Defines of the material we want to update
  9582. * @param lightIndex Index of the light in the enabled light list of the material
  9583. */
  9584. prepareDefines(defines: any, lightIndex: number): void;
  9585. /**
  9586. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9587. * defined in the generator but impacting the effect).
  9588. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9589. * @param effect The effect we are binfing the information for
  9590. */
  9591. bindShadowLight(lightIndex: string, effect: Effect): void;
  9592. /**
  9593. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9594. * (eq to shadow prjection matrix * light transform matrix)
  9595. * @returns The transform matrix used to create the shadow map
  9596. */
  9597. getTransformMatrix(): Matrix;
  9598. /**
  9599. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9600. * Cube and 2D textures for instance.
  9601. */
  9602. recreateShadowMap(): void;
  9603. private _disposeBlurPostProcesses;
  9604. private _disposeRTTandPostProcesses;
  9605. /**
  9606. * Disposes the ShadowGenerator.
  9607. * Returns nothing.
  9608. */
  9609. dispose(): void;
  9610. /**
  9611. * Serializes the shadow generator setup to a json object.
  9612. * @returns The serialized JSON object
  9613. */
  9614. serialize(): any;
  9615. /**
  9616. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9617. * @param parsedShadowGenerator The JSON object to parse
  9618. * @param scene The scene to create the shadow map for
  9619. * @returns The parsed shadow generator
  9620. */
  9621. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9622. }
  9623. }
  9624. declare module BABYLON {
  9625. /**
  9626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9628. * 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.
  9629. */
  9630. export abstract class Light extends Node {
  9631. /**
  9632. * Falloff Default: light is falling off following the material specification:
  9633. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9634. */
  9635. static readonly FALLOFF_DEFAULT: number;
  9636. /**
  9637. * Falloff Physical: light is falling off following the inverse squared distance law.
  9638. */
  9639. static readonly FALLOFF_PHYSICAL: number;
  9640. /**
  9641. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9642. * to enhance interoperability with other engines.
  9643. */
  9644. static readonly FALLOFF_GLTF: number;
  9645. /**
  9646. * Falloff Standard: light is falling off like in the standard material
  9647. * to enhance interoperability with other materials.
  9648. */
  9649. static readonly FALLOFF_STANDARD: number;
  9650. /**
  9651. * If every light affecting the material is in this lightmapMode,
  9652. * material.lightmapTexture adds or multiplies
  9653. * (depends on material.useLightmapAsShadowmap)
  9654. * after every other light calculations.
  9655. */
  9656. static readonly LIGHTMAP_DEFAULT: number;
  9657. /**
  9658. * material.lightmapTexture as only diffuse lighting from this light
  9659. * adds only specular lighting from this light
  9660. * adds dynamic shadows
  9661. */
  9662. static readonly LIGHTMAP_SPECULAR: number;
  9663. /**
  9664. * material.lightmapTexture as only lighting
  9665. * no light calculation from this light
  9666. * only adds dynamic shadows from this light
  9667. */
  9668. static readonly LIGHTMAP_SHADOWSONLY: number;
  9669. /**
  9670. * Each light type uses the default quantity according to its type:
  9671. * point/spot lights use luminous intensity
  9672. * directional lights use illuminance
  9673. */
  9674. static readonly INTENSITYMODE_AUTOMATIC: number;
  9675. /**
  9676. * lumen (lm)
  9677. */
  9678. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9679. /**
  9680. * candela (lm/sr)
  9681. */
  9682. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9683. /**
  9684. * lux (lm/m^2)
  9685. */
  9686. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9687. /**
  9688. * nit (cd/m^2)
  9689. */
  9690. static readonly INTENSITYMODE_LUMINANCE: number;
  9691. /**
  9692. * Light type const id of the point light.
  9693. */
  9694. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9695. /**
  9696. * Light type const id of the directional light.
  9697. */
  9698. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9699. /**
  9700. * Light type const id of the spot light.
  9701. */
  9702. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9703. /**
  9704. * Light type const id of the hemispheric light.
  9705. */
  9706. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9707. /**
  9708. * Diffuse gives the basic color to an object.
  9709. */
  9710. diffuse: Color3;
  9711. /**
  9712. * Specular produces a highlight color on an object.
  9713. * Note: This is note affecting PBR materials.
  9714. */
  9715. specular: Color3;
  9716. /**
  9717. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9718. * falling off base on range or angle.
  9719. * This can be set to any values in Light.FALLOFF_x.
  9720. *
  9721. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9722. * other types of materials.
  9723. */
  9724. falloffType: number;
  9725. /**
  9726. * Strength of the light.
  9727. * Note: By default it is define in the framework own unit.
  9728. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9729. */
  9730. intensity: number;
  9731. private _range;
  9732. protected _inverseSquaredRange: number;
  9733. /**
  9734. * Defines how far from the source the light is impacting in scene units.
  9735. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9736. */
  9737. /**
  9738. * Defines how far from the source the light is impacting in scene units.
  9739. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9740. */
  9741. range: number;
  9742. /**
  9743. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9744. * of light.
  9745. */
  9746. private _photometricScale;
  9747. private _intensityMode;
  9748. /**
  9749. * Gets the photometric scale used to interpret the intensity.
  9750. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9751. */
  9752. /**
  9753. * Sets the photometric scale used to interpret the intensity.
  9754. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9755. */
  9756. intensityMode: number;
  9757. private _radius;
  9758. /**
  9759. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9760. */
  9761. /**
  9762. * sets the light radius used by PBR Materials to simulate soft area lights.
  9763. */
  9764. radius: number;
  9765. private _renderPriority;
  9766. /**
  9767. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9768. * exceeding the number allowed of the materials.
  9769. */
  9770. renderPriority: number;
  9771. private _shadowEnabled;
  9772. /**
  9773. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9774. * the current shadow generator.
  9775. */
  9776. /**
  9777. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9778. * the current shadow generator.
  9779. */
  9780. shadowEnabled: boolean;
  9781. private _includedOnlyMeshes;
  9782. /**
  9783. * Gets the only meshes impacted by this light.
  9784. */
  9785. /**
  9786. * Sets the only meshes impacted by this light.
  9787. */
  9788. includedOnlyMeshes: AbstractMesh[];
  9789. private _excludedMeshes;
  9790. /**
  9791. * Gets the meshes not impacted by this light.
  9792. */
  9793. /**
  9794. * Sets the meshes not impacted by this light.
  9795. */
  9796. excludedMeshes: AbstractMesh[];
  9797. private _excludeWithLayerMask;
  9798. /**
  9799. * Gets the layer id use to find what meshes are not impacted by the light.
  9800. * Inactive if 0
  9801. */
  9802. /**
  9803. * Sets the layer id use to find what meshes are not impacted by the light.
  9804. * Inactive if 0
  9805. */
  9806. excludeWithLayerMask: number;
  9807. private _includeOnlyWithLayerMask;
  9808. /**
  9809. * Gets the layer id use to find what meshes are impacted by the light.
  9810. * Inactive if 0
  9811. */
  9812. /**
  9813. * Sets the layer id use to find what meshes are impacted by the light.
  9814. * Inactive if 0
  9815. */
  9816. includeOnlyWithLayerMask: number;
  9817. private _lightmapMode;
  9818. /**
  9819. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9820. */
  9821. /**
  9822. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9823. */
  9824. lightmapMode: number;
  9825. /**
  9826. * Shadow generator associted to the light.
  9827. * @hidden Internal use only.
  9828. */
  9829. _shadowGenerator: Nullable<IShadowGenerator>;
  9830. /**
  9831. * @hidden Internal use only.
  9832. */
  9833. _excludedMeshesIds: string[];
  9834. /**
  9835. * @hidden Internal use only.
  9836. */
  9837. _includedOnlyMeshesIds: string[];
  9838. /**
  9839. * The current light unifom buffer.
  9840. * @hidden Internal use only.
  9841. */
  9842. _uniformBuffer: UniformBuffer;
  9843. /**
  9844. * Creates a Light object in the scene.
  9845. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9846. * @param name The firendly name of the light
  9847. * @param scene The scene the light belongs too
  9848. */
  9849. constructor(name: string, scene: Scene);
  9850. protected abstract _buildUniformLayout(): void;
  9851. /**
  9852. * Sets the passed Effect "effect" with the Light information.
  9853. * @param effect The effect to update
  9854. * @param lightIndex The index of the light in the effect to update
  9855. * @returns The light
  9856. */
  9857. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9858. /**
  9859. * Returns the string "Light".
  9860. * @returns the class name
  9861. */
  9862. getClassName(): string;
  9863. /** @hidden */
  9864. readonly _isLight: boolean;
  9865. /**
  9866. * Converts the light information to a readable string for debug purpose.
  9867. * @param fullDetails Supports for multiple levels of logging within scene loading
  9868. * @returns the human readable light info
  9869. */
  9870. toString(fullDetails?: boolean): string;
  9871. /** @hidden */
  9872. protected _syncParentEnabledState(): void;
  9873. /**
  9874. * Set the enabled state of this node.
  9875. * @param value - the new enabled state
  9876. */
  9877. setEnabled(value: boolean): void;
  9878. /**
  9879. * Returns the Light associated shadow generator if any.
  9880. * @return the associated shadow generator.
  9881. */
  9882. getShadowGenerator(): Nullable<IShadowGenerator>;
  9883. /**
  9884. * Returns a Vector3, the absolute light position in the World.
  9885. * @returns the world space position of the light
  9886. */
  9887. getAbsolutePosition(): Vector3;
  9888. /**
  9889. * Specifies if the light will affect the passed mesh.
  9890. * @param mesh The mesh to test against the light
  9891. * @return true the mesh is affected otherwise, false.
  9892. */
  9893. canAffectMesh(mesh: AbstractMesh): boolean;
  9894. /**
  9895. * Sort function to order lights for rendering.
  9896. * @param a First Light object to compare to second.
  9897. * @param b Second Light object to compare first.
  9898. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9899. */
  9900. static CompareLightsPriority(a: Light, b: Light): number;
  9901. /**
  9902. * Releases resources associated with this node.
  9903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9905. */
  9906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9907. /**
  9908. * Returns the light type ID (integer).
  9909. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9910. */
  9911. getTypeID(): number;
  9912. /**
  9913. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9914. * @returns the scaled intensity in intensity mode unit
  9915. */
  9916. getScaledIntensity(): number;
  9917. /**
  9918. * Returns a new Light object, named "name", from the current one.
  9919. * @param name The name of the cloned light
  9920. * @returns the new created light
  9921. */
  9922. clone(name: string): Nullable<Light>;
  9923. /**
  9924. * Serializes the current light into a Serialization object.
  9925. * @returns the serialized object.
  9926. */
  9927. serialize(): any;
  9928. /**
  9929. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9930. * This new light is named "name" and added to the passed scene.
  9931. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9932. * @param name The friendly name of the light
  9933. * @param scene The scene the new light will belong to
  9934. * @returns the constructor function
  9935. */
  9936. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9937. /**
  9938. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9939. * @param parsedLight The JSON representation of the light
  9940. * @param scene The scene to create the parsed light in
  9941. * @returns the created light after parsing
  9942. */
  9943. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9944. private _hookArrayForExcluded;
  9945. private _hookArrayForIncludedOnly;
  9946. private _resyncMeshes;
  9947. /**
  9948. * Forces the meshes to update their light related information in their rendering used effects
  9949. * @hidden Internal Use Only
  9950. */
  9951. _markMeshesAsLightDirty(): void;
  9952. /**
  9953. * Recomputes the cached photometric scale if needed.
  9954. */
  9955. private _computePhotometricScale;
  9956. /**
  9957. * Returns the Photometric Scale according to the light type and intensity mode.
  9958. */
  9959. private _getPhotometricScale;
  9960. /**
  9961. * Reorder the light in the scene according to their defined priority.
  9962. * @hidden Internal Use Only
  9963. */
  9964. _reorderLightsInScene(): void;
  9965. /**
  9966. * Prepares the list of defines specific to the light type.
  9967. * @param defines the list of defines
  9968. * @param lightIndex defines the index of the light for the effect
  9969. */
  9970. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Interface used to define Action
  9976. */
  9977. export interface IAction {
  9978. /**
  9979. * Trigger for the action
  9980. */
  9981. trigger: number;
  9982. /** Options of the trigger */
  9983. triggerOptions: any;
  9984. /**
  9985. * Gets the trigger parameters
  9986. * @returns the trigger parameters
  9987. */
  9988. getTriggerParameter(): any;
  9989. /**
  9990. * Internal only - executes current action event
  9991. * @hidden
  9992. */
  9993. _executeCurrent(evt?: ActionEvent): void;
  9994. /**
  9995. * Serialize placeholder for child classes
  9996. * @param parent of child
  9997. * @returns the serialized object
  9998. */
  9999. serialize(parent: any): any;
  10000. /**
  10001. * Internal only
  10002. * @hidden
  10003. */
  10004. _prepare(): void;
  10005. /**
  10006. * Internal only - manager for action
  10007. * @hidden
  10008. */
  10009. _actionManager: AbstractActionManager;
  10010. /**
  10011. * Adds action to chain of actions, may be a DoNothingAction
  10012. * @param action defines the next action to execute
  10013. * @returns The action passed in
  10014. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10015. */
  10016. then(action: IAction): IAction;
  10017. }
  10018. /**
  10019. * The action to be carried out following a trigger
  10020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10021. */
  10022. export class Action implements IAction {
  10023. /** the trigger, with or without parameters, for the action */
  10024. triggerOptions: any;
  10025. /**
  10026. * Trigger for the action
  10027. */
  10028. trigger: number;
  10029. /**
  10030. * Internal only - manager for action
  10031. * @hidden
  10032. */
  10033. _actionManager: ActionManager;
  10034. private _nextActiveAction;
  10035. private _child;
  10036. private _condition?;
  10037. private _triggerParameter;
  10038. /**
  10039. * An event triggered prior to action being executed.
  10040. */
  10041. onBeforeExecuteObservable: Observable<Action>;
  10042. /**
  10043. * Creates a new Action
  10044. * @param triggerOptions the trigger, with or without parameters, for the action
  10045. * @param condition an optional determinant of action
  10046. */
  10047. constructor(
  10048. /** the trigger, with or without parameters, for the action */
  10049. triggerOptions: any, condition?: Condition);
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */
  10054. _prepare(): void;
  10055. /**
  10056. * Gets the trigger parameters
  10057. * @returns the trigger parameters
  10058. */
  10059. getTriggerParameter(): any;
  10060. /**
  10061. * Internal only - executes current action event
  10062. * @hidden
  10063. */
  10064. _executeCurrent(evt?: ActionEvent): void;
  10065. /**
  10066. * Execute placeholder for child classes
  10067. * @param evt optional action event
  10068. */
  10069. execute(evt?: ActionEvent): void;
  10070. /**
  10071. * Skips to next active action
  10072. */
  10073. skipToNextActiveAction(): void;
  10074. /**
  10075. * Adds action to chain of actions, may be a DoNothingAction
  10076. * @param action defines the next action to execute
  10077. * @returns The action passed in
  10078. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10079. */
  10080. then(action: Action): Action;
  10081. /**
  10082. * Internal only
  10083. * @hidden
  10084. */
  10085. _getProperty(propertyPath: string): string;
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. _getEffectiveTarget(target: any, propertyPath: string): any;
  10091. /**
  10092. * Serialize placeholder for child classes
  10093. * @param parent of child
  10094. * @returns the serialized object
  10095. */
  10096. serialize(parent: any): any;
  10097. /**
  10098. * Internal only called by serialize
  10099. * @hidden
  10100. */
  10101. protected _serialize(serializedAction: any, parent?: any): any;
  10102. /**
  10103. * Internal only
  10104. * @hidden
  10105. */
  10106. static _SerializeValueAsString: (value: any) => string;
  10107. /**
  10108. * Internal only
  10109. * @hidden
  10110. */
  10111. static _GetTargetProperty: (target: Node | Scene) => {
  10112. name: string;
  10113. targetType: string;
  10114. value: string;
  10115. };
  10116. }
  10117. }
  10118. declare module BABYLON {
  10119. /**
  10120. * A Condition applied to an Action
  10121. */
  10122. export class Condition {
  10123. /**
  10124. * Internal only - manager for action
  10125. * @hidden
  10126. */
  10127. _actionManager: ActionManager;
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _evaluationId: number;
  10133. /**
  10134. * Internal only
  10135. * @hidden
  10136. */
  10137. _currentResult: boolean;
  10138. /**
  10139. * Creates a new Condition
  10140. * @param actionManager the manager of the action the condition is applied to
  10141. */
  10142. constructor(actionManager: ActionManager);
  10143. /**
  10144. * Check if the current condition is valid
  10145. * @returns a boolean
  10146. */
  10147. isValid(): boolean;
  10148. /**
  10149. * Internal only
  10150. * @hidden
  10151. */
  10152. _getProperty(propertyPath: string): string;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _getEffectiveTarget(target: any, propertyPath: string): any;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @returns the serialized object
  10161. */
  10162. serialize(): any;
  10163. /**
  10164. * Internal only
  10165. * @hidden
  10166. */
  10167. protected _serialize(serializedCondition: any): any;
  10168. }
  10169. /**
  10170. * Defines specific conditional operators as extensions of Condition
  10171. */
  10172. export class ValueCondition extends Condition {
  10173. /** path to specify the property of the target the conditional operator uses */
  10174. propertyPath: string;
  10175. /** the value compared by the conditional operator against the current value of the property */
  10176. value: any;
  10177. /** the conditional operator, default ValueCondition.IsEqual */
  10178. operator: number;
  10179. /**
  10180. * Internal only
  10181. * @hidden
  10182. */
  10183. private static _IsEqual;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsDifferent;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsGreater;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. private static _IsLesser;
  10199. /**
  10200. * returns the number for IsEqual
  10201. */
  10202. static readonly IsEqual: number;
  10203. /**
  10204. * Returns the number for IsDifferent
  10205. */
  10206. static readonly IsDifferent: number;
  10207. /**
  10208. * Returns the number for IsGreater
  10209. */
  10210. static readonly IsGreater: number;
  10211. /**
  10212. * Returns the number for IsLesser
  10213. */
  10214. static readonly IsLesser: number;
  10215. /**
  10216. * Internal only The action manager for the condition
  10217. * @hidden
  10218. */
  10219. _actionManager: ActionManager;
  10220. /**
  10221. * Internal only
  10222. * @hidden
  10223. */
  10224. private _target;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _effectiveTarget;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. private _property;
  10235. /**
  10236. * Creates a new ValueCondition
  10237. * @param actionManager manager for the action the condition applies to
  10238. * @param target for the action
  10239. * @param propertyPath path to specify the property of the target the conditional operator uses
  10240. * @param value the value compared by the conditional operator against the current value of the property
  10241. * @param operator the conditional operator, default ValueCondition.IsEqual
  10242. */
  10243. constructor(actionManager: ActionManager, target: any,
  10244. /** path to specify the property of the target the conditional operator uses */
  10245. propertyPath: string,
  10246. /** the value compared by the conditional operator against the current value of the property */
  10247. value: any,
  10248. /** the conditional operator, default ValueCondition.IsEqual */
  10249. operator?: number);
  10250. /**
  10251. * Compares the given value with the property value for the specified conditional operator
  10252. * @returns the result of the comparison
  10253. */
  10254. isValid(): boolean;
  10255. /**
  10256. * Serialize the ValueCondition into a JSON compatible object
  10257. * @returns serialization object
  10258. */
  10259. serialize(): any;
  10260. /**
  10261. * Gets the name of the conditional operator for the ValueCondition
  10262. * @param operator the conditional operator
  10263. * @returns the name
  10264. */
  10265. static GetOperatorName(operator: number): string;
  10266. }
  10267. /**
  10268. * Defines a predicate condition as an extension of Condition
  10269. */
  10270. export class PredicateCondition extends Condition {
  10271. /** defines the predicate function used to validate the condition */
  10272. predicate: () => boolean;
  10273. /**
  10274. * Internal only - manager for action
  10275. * @hidden
  10276. */
  10277. _actionManager: ActionManager;
  10278. /**
  10279. * Creates a new PredicateCondition
  10280. * @param actionManager manager for the action the condition applies to
  10281. * @param predicate defines the predicate function used to validate the condition
  10282. */
  10283. constructor(actionManager: ActionManager,
  10284. /** defines the predicate function used to validate the condition */
  10285. predicate: () => boolean);
  10286. /**
  10287. * @returns the validity of the predicate condition
  10288. */
  10289. isValid(): boolean;
  10290. }
  10291. /**
  10292. * Defines a state condition as an extension of Condition
  10293. */
  10294. export class StateCondition extends Condition {
  10295. /** Value to compare with target state */
  10296. value: string;
  10297. /**
  10298. * Internal only - manager for action
  10299. * @hidden
  10300. */
  10301. _actionManager: ActionManager;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. private _target;
  10307. /**
  10308. * Creates a new StateCondition
  10309. * @param actionManager manager for the action the condition applies to
  10310. * @param target of the condition
  10311. * @param value to compare with target state
  10312. */
  10313. constructor(actionManager: ActionManager, target: any,
  10314. /** Value to compare with target state */
  10315. value: string);
  10316. /**
  10317. * Gets a boolean indicating if the current condition is met
  10318. * @returns the validity of the state
  10319. */
  10320. isValid(): boolean;
  10321. /**
  10322. * Serialize the StateCondition into a JSON compatible object
  10323. * @returns serialization object
  10324. */
  10325. serialize(): any;
  10326. }
  10327. }
  10328. declare module BABYLON {
  10329. /**
  10330. * This defines an action responsible to toggle a boolean once triggered.
  10331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10332. */
  10333. export class SwitchBooleanAction extends Action {
  10334. /**
  10335. * The path to the boolean property in the target object
  10336. */
  10337. propertyPath: string;
  10338. private _target;
  10339. private _effectiveTarget;
  10340. private _property;
  10341. /**
  10342. * Instantiate the action
  10343. * @param triggerOptions defines the trigger options
  10344. * @param target defines the object containing the boolean
  10345. * @param propertyPath defines the path to the boolean property in the target object
  10346. * @param condition defines the trigger related conditions
  10347. */
  10348. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10349. /** @hidden */
  10350. _prepare(): void;
  10351. /**
  10352. * Execute the action toggle the boolean value.
  10353. */
  10354. execute(): void;
  10355. /**
  10356. * Serializes the actions and its related information.
  10357. * @param parent defines the object to serialize in
  10358. * @returns the serialized object
  10359. */
  10360. serialize(parent: any): any;
  10361. }
  10362. /**
  10363. * This defines an action responsible to set a the state field of the target
  10364. * to a desired value once triggered.
  10365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10366. */
  10367. export class SetStateAction extends Action {
  10368. /**
  10369. * The value to store in the state field.
  10370. */
  10371. value: string;
  10372. private _target;
  10373. /**
  10374. * Instantiate the action
  10375. * @param triggerOptions defines the trigger options
  10376. * @param target defines the object containing the state property
  10377. * @param value defines the value to store in the state field
  10378. * @param condition defines the trigger related conditions
  10379. */
  10380. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10381. /**
  10382. * Execute the action and store the value on the target state property.
  10383. */
  10384. execute(): void;
  10385. /**
  10386. * Serializes the actions and its related information.
  10387. * @param parent defines the object to serialize in
  10388. * @returns the serialized object
  10389. */
  10390. serialize(parent: any): any;
  10391. }
  10392. /**
  10393. * This defines an action responsible to set a property of the target
  10394. * to a desired value once triggered.
  10395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10396. */
  10397. export class SetValueAction extends Action {
  10398. /**
  10399. * The path of the property to set in the target.
  10400. */
  10401. propertyPath: string;
  10402. /**
  10403. * The value to set in the property
  10404. */
  10405. value: any;
  10406. private _target;
  10407. private _effectiveTarget;
  10408. private _property;
  10409. /**
  10410. * Instantiate the action
  10411. * @param triggerOptions defines the trigger options
  10412. * @param target defines the object containing the property
  10413. * @param propertyPath defines the path of the property to set in the target
  10414. * @param value defines the value to set in the property
  10415. * @param condition defines the trigger related conditions
  10416. */
  10417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10418. /** @hidden */
  10419. _prepare(): void;
  10420. /**
  10421. * Execute the action and set the targetted property to the desired value.
  10422. */
  10423. execute(): void;
  10424. /**
  10425. * Serializes the actions and its related information.
  10426. * @param parent defines the object to serialize in
  10427. * @returns the serialized object
  10428. */
  10429. serialize(parent: any): any;
  10430. }
  10431. /**
  10432. * This defines an action responsible to increment the target value
  10433. * to a desired value once triggered.
  10434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10435. */
  10436. export class IncrementValueAction extends Action {
  10437. /**
  10438. * The path of the property to increment in the target.
  10439. */
  10440. propertyPath: string;
  10441. /**
  10442. * The value we should increment the property by.
  10443. */
  10444. value: any;
  10445. private _target;
  10446. private _effectiveTarget;
  10447. private _property;
  10448. /**
  10449. * Instantiate the action
  10450. * @param triggerOptions defines the trigger options
  10451. * @param target defines the object containing the property
  10452. * @param propertyPath defines the path of the property to increment in the target
  10453. * @param value defines the value value we should increment the property by
  10454. * @param condition defines the trigger related conditions
  10455. */
  10456. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10457. /** @hidden */
  10458. _prepare(): void;
  10459. /**
  10460. * Execute the action and increment the target of the value amount.
  10461. */
  10462. execute(): void;
  10463. /**
  10464. * Serializes the actions and its related information.
  10465. * @param parent defines the object to serialize in
  10466. * @returns the serialized object
  10467. */
  10468. serialize(parent: any): any;
  10469. }
  10470. /**
  10471. * This defines an action responsible to start an animation once triggered.
  10472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10473. */
  10474. export class PlayAnimationAction extends Action {
  10475. /**
  10476. * Where the animation should start (animation frame)
  10477. */
  10478. from: number;
  10479. /**
  10480. * Where the animation should stop (animation frame)
  10481. */
  10482. to: number;
  10483. /**
  10484. * Define if the animation should loop or stop after the first play.
  10485. */
  10486. loop?: boolean;
  10487. private _target;
  10488. /**
  10489. * Instantiate the action
  10490. * @param triggerOptions defines the trigger options
  10491. * @param target defines the target animation or animation name
  10492. * @param from defines from where the animation should start (animation frame)
  10493. * @param end defines where the animation should stop (animation frame)
  10494. * @param loop defines if the animation should loop or stop after the first play
  10495. * @param condition defines the trigger related conditions
  10496. */
  10497. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10498. /** @hidden */
  10499. _prepare(): void;
  10500. /**
  10501. * Execute the action and play the animation.
  10502. */
  10503. execute(): void;
  10504. /**
  10505. * Serializes the actions and its related information.
  10506. * @param parent defines the object to serialize in
  10507. * @returns the serialized object
  10508. */
  10509. serialize(parent: any): any;
  10510. }
  10511. /**
  10512. * This defines an action responsible to stop an animation once triggered.
  10513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10514. */
  10515. export class StopAnimationAction extends Action {
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the target animation or animation name
  10521. * @param condition defines the trigger related conditions
  10522. */
  10523. constructor(triggerOptions: any, target: any, condition?: Condition);
  10524. /** @hidden */
  10525. _prepare(): void;
  10526. /**
  10527. * Execute the action and stop the animation.
  10528. */
  10529. execute(): void;
  10530. /**
  10531. * Serializes the actions and its related information.
  10532. * @param parent defines the object to serialize in
  10533. * @returns the serialized object
  10534. */
  10535. serialize(parent: any): any;
  10536. }
  10537. /**
  10538. * This defines an action responsible that does nothing once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class DoNothingAction extends Action {
  10542. /**
  10543. * Instantiate the action
  10544. * @param triggerOptions defines the trigger options
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions?: any, condition?: Condition);
  10548. /**
  10549. * Execute the action and do nothing.
  10550. */
  10551. execute(): void;
  10552. /**
  10553. * Serializes the actions and its related information.
  10554. * @param parent defines the object to serialize in
  10555. * @returns the serialized object
  10556. */
  10557. serialize(parent: any): any;
  10558. }
  10559. /**
  10560. * This defines an action responsible to trigger several actions once triggered.
  10561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10562. */
  10563. export class CombineAction extends Action {
  10564. /**
  10565. * The list of aggregated animations to run.
  10566. */
  10567. children: Action[];
  10568. /**
  10569. * Instantiate the action
  10570. * @param triggerOptions defines the trigger options
  10571. * @param children defines the list of aggregated animations to run
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10575. /** @hidden */
  10576. _prepare(): void;
  10577. /**
  10578. * Execute the action and executes all the aggregated actions.
  10579. */
  10580. execute(evt: ActionEvent): void;
  10581. /**
  10582. * Serializes the actions and its related information.
  10583. * @param parent defines the object to serialize in
  10584. * @returns the serialized object
  10585. */
  10586. serialize(parent: any): any;
  10587. }
  10588. /**
  10589. * This defines an action responsible to run code (external event) once triggered.
  10590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10591. */
  10592. export class ExecuteCodeAction extends Action {
  10593. /**
  10594. * The callback function to run.
  10595. */
  10596. func: (evt: ActionEvent) => void;
  10597. /**
  10598. * Instantiate the action
  10599. * @param triggerOptions defines the trigger options
  10600. * @param func defines the callback function to run
  10601. * @param condition defines the trigger related conditions
  10602. */
  10603. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10604. /**
  10605. * Execute the action and run the attached code.
  10606. */
  10607. execute(evt: ActionEvent): void;
  10608. }
  10609. /**
  10610. * This defines an action responsible to set the parent property of the target once triggered.
  10611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10612. */
  10613. export class SetParentAction extends Action {
  10614. private _parent;
  10615. private _target;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the target containing the parent property
  10620. * @param parent defines from where the animation should start (animation frame)
  10621. * @param condition defines the trigger related conditions
  10622. */
  10623. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10624. /** @hidden */
  10625. _prepare(): void;
  10626. /**
  10627. * Execute the action and set the parent property.
  10628. */
  10629. execute(): void;
  10630. /**
  10631. * Serializes the actions and its related information.
  10632. * @param parent defines the object to serialize in
  10633. * @returns the serialized object
  10634. */
  10635. serialize(parent: any): any;
  10636. }
  10637. }
  10638. declare module BABYLON {
  10639. /**
  10640. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10641. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10643. */
  10644. export class ActionManager extends AbstractActionManager {
  10645. /**
  10646. * Nothing
  10647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10648. */
  10649. static readonly NothingTrigger: number;
  10650. /**
  10651. * On pick
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly OnPickTrigger: number;
  10655. /**
  10656. * On left pick
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnLeftPickTrigger: number;
  10660. /**
  10661. * On right pick
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnRightPickTrigger: number;
  10665. /**
  10666. * On center pick
  10667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnCenterPickTrigger: number;
  10670. /**
  10671. * On pick down
  10672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnPickDownTrigger: number;
  10675. /**
  10676. * On double pick
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnDoublePickTrigger: number;
  10680. /**
  10681. * On pick up
  10682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnPickUpTrigger: number;
  10685. /**
  10686. * On pick out.
  10687. * This trigger will only be raised if you also declared a OnPickDown
  10688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10689. */
  10690. static readonly OnPickOutTrigger: number;
  10691. /**
  10692. * On long press
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnLongPressTrigger: number;
  10696. /**
  10697. * On pointer over
  10698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnPointerOverTrigger: number;
  10701. /**
  10702. * On pointer out
  10703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnPointerOutTrigger: number;
  10706. /**
  10707. * On every frame
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnEveryFrameTrigger: number;
  10711. /**
  10712. * On intersection enter
  10713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnIntersectionEnterTrigger: number;
  10716. /**
  10717. * On intersection exit
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnIntersectionExitTrigger: number;
  10721. /**
  10722. * On key down
  10723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnKeyDownTrigger: number;
  10726. /**
  10727. * On key up
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10729. */
  10730. static readonly OnKeyUpTrigger: number;
  10731. private _scene;
  10732. /**
  10733. * Creates a new action manager
  10734. * @param scene defines the hosting scene
  10735. */
  10736. constructor(scene: Scene);
  10737. /**
  10738. * Releases all associated resources
  10739. */
  10740. dispose(): void;
  10741. /**
  10742. * Gets hosting scene
  10743. * @returns the hosting scene
  10744. */
  10745. getScene(): Scene;
  10746. /**
  10747. * Does this action manager handles actions of any of the given triggers
  10748. * @param triggers defines the triggers to be tested
  10749. * @return a boolean indicating whether one (or more) of the triggers is handled
  10750. */
  10751. hasSpecificTriggers(triggers: number[]): boolean;
  10752. /**
  10753. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10754. * speed.
  10755. * @param triggerA defines the trigger to be tested
  10756. * @param triggerB defines the trigger to be tested
  10757. * @return a boolean indicating whether one (or more) of the triggers is handled
  10758. */
  10759. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10760. /**
  10761. * Does this action manager handles actions of a given trigger
  10762. * @param trigger defines the trigger to be tested
  10763. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10764. * @return whether the trigger is handled
  10765. */
  10766. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10767. /**
  10768. * Does this action manager has pointer triggers
  10769. */
  10770. readonly hasPointerTriggers: boolean;
  10771. /**
  10772. * Does this action manager has pick triggers
  10773. */
  10774. readonly hasPickTriggers: boolean;
  10775. /**
  10776. * Registers an action to this action manager
  10777. * @param action defines the action to be registered
  10778. * @return the action amended (prepared) after registration
  10779. */
  10780. registerAction(action: IAction): Nullable<IAction>;
  10781. /**
  10782. * Unregisters an action to this action manager
  10783. * @param action defines the action to be unregistered
  10784. * @return a boolean indicating whether the action has been unregistered
  10785. */
  10786. unregisterAction(action: IAction): Boolean;
  10787. /**
  10788. * Process a specific trigger
  10789. * @param trigger defines the trigger to process
  10790. * @param evt defines the event details to be processed
  10791. */
  10792. processTrigger(trigger: number, evt?: IActionEvent): void;
  10793. /** @hidden */
  10794. _getEffectiveTarget(target: any, propertyPath: string): any;
  10795. /** @hidden */
  10796. _getProperty(propertyPath: string): string;
  10797. /**
  10798. * Serialize this manager to a JSON object
  10799. * @param name defines the property name to store this manager
  10800. * @returns a JSON representation of this manager
  10801. */
  10802. serialize(name: string): any;
  10803. /**
  10804. * Creates a new ActionManager from a JSON data
  10805. * @param parsedActions defines the JSON data to read from
  10806. * @param object defines the hosting mesh
  10807. * @param scene defines the hosting scene
  10808. */
  10809. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10810. /**
  10811. * Get a trigger name by index
  10812. * @param trigger defines the trigger index
  10813. * @returns a trigger name
  10814. */
  10815. static GetTriggerName(trigger: number): string;
  10816. }
  10817. }
  10818. declare module BABYLON {
  10819. /**
  10820. * Class representing a ray with position and direction
  10821. */
  10822. export class Ray {
  10823. /** origin point */
  10824. origin: Vector3;
  10825. /** direction */
  10826. direction: Vector3;
  10827. /** length of the ray */
  10828. length: number;
  10829. private static readonly TmpVector3;
  10830. private _tmpRay;
  10831. /**
  10832. * Creates a new ray
  10833. * @param origin origin point
  10834. * @param direction direction
  10835. * @param length length of the ray
  10836. */
  10837. constructor(
  10838. /** origin point */
  10839. origin: Vector3,
  10840. /** direction */
  10841. direction: Vector3,
  10842. /** length of the ray */
  10843. length?: number);
  10844. /**
  10845. * Checks if the ray intersects a box
  10846. * @param minimum bound of the box
  10847. * @param maximum bound of the box
  10848. * @param intersectionTreshold extra extend to be added to the box in all direction
  10849. * @returns if the box was hit
  10850. */
  10851. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10852. /**
  10853. * Checks if the ray intersects a box
  10854. * @param box the bounding box to check
  10855. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10856. * @returns if the box was hit
  10857. */
  10858. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10859. /**
  10860. * If the ray hits a sphere
  10861. * @param sphere the bounding sphere to check
  10862. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10863. * @returns true if it hits the sphere
  10864. */
  10865. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10866. /**
  10867. * If the ray hits a triange
  10868. * @param vertex0 triangle vertex
  10869. * @param vertex1 triangle vertex
  10870. * @param vertex2 triangle vertex
  10871. * @returns intersection information if hit
  10872. */
  10873. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10874. /**
  10875. * Checks if ray intersects a plane
  10876. * @param plane the plane to check
  10877. * @returns the distance away it was hit
  10878. */
  10879. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10880. /**
  10881. * Calculate the intercept of a ray on a given axis
  10882. * @param axis to check 'x' | 'y' | 'z'
  10883. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10884. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10885. */
  10886. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10887. /**
  10888. * Checks if ray intersects a mesh
  10889. * @param mesh the mesh to check
  10890. * @param fastCheck if only the bounding box should checked
  10891. * @returns picking info of the intersecton
  10892. */
  10893. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10894. /**
  10895. * Checks if ray intersects a mesh
  10896. * @param meshes the meshes to check
  10897. * @param fastCheck if only the bounding box should checked
  10898. * @param results array to store result in
  10899. * @returns Array of picking infos
  10900. */
  10901. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10902. private _comparePickingInfo;
  10903. private static smallnum;
  10904. private static rayl;
  10905. /**
  10906. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10907. * @param sega the first point of the segment to test the intersection against
  10908. * @param segb the second point of the segment to test the intersection against
  10909. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10910. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10911. */
  10912. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10913. /**
  10914. * Update the ray from viewport position
  10915. * @param x position
  10916. * @param y y position
  10917. * @param viewportWidth viewport width
  10918. * @param viewportHeight viewport height
  10919. * @param world world matrix
  10920. * @param view view matrix
  10921. * @param projection projection matrix
  10922. * @returns this ray updated
  10923. */
  10924. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10925. /**
  10926. * Creates a ray with origin and direction of 0,0,0
  10927. * @returns the new ray
  10928. */
  10929. static Zero(): Ray;
  10930. /**
  10931. * Creates a new ray from screen space and viewport
  10932. * @param x position
  10933. * @param y y position
  10934. * @param viewportWidth viewport width
  10935. * @param viewportHeight viewport height
  10936. * @param world world matrix
  10937. * @param view view matrix
  10938. * @param projection projection matrix
  10939. * @returns new ray
  10940. */
  10941. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10942. /**
  10943. * 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
  10944. * transformed to the given world matrix.
  10945. * @param origin The origin point
  10946. * @param end The end point
  10947. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10948. * @returns the new ray
  10949. */
  10950. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10951. /**
  10952. * Transforms a ray by a matrix
  10953. * @param ray ray to transform
  10954. * @param matrix matrix to apply
  10955. * @returns the resulting new ray
  10956. */
  10957. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Transforms a ray by a matrix
  10960. * @param ray ray to transform
  10961. * @param matrix matrix to apply
  10962. * @param result ray to store result in
  10963. */
  10964. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10965. /**
  10966. * Unproject a ray from screen space to object space
  10967. * @param sourceX defines the screen space x coordinate to use
  10968. * @param sourceY defines the screen space y coordinate to use
  10969. * @param viewportWidth defines the current width of the viewport
  10970. * @param viewportHeight defines the current height of the viewport
  10971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10972. * @param view defines the view matrix to use
  10973. * @param projection defines the projection matrix to use
  10974. */
  10975. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10976. }
  10977. /**
  10978. * Type used to define predicate used to select faces when a mesh intersection is detected
  10979. */
  10980. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10981. interface Scene {
  10982. /** @hidden */
  10983. _tempPickingRay: Nullable<Ray>;
  10984. /** @hidden */
  10985. _cachedRayForTransform: Ray;
  10986. /** @hidden */
  10987. _pickWithRayInverseMatrix: Matrix;
  10988. /** @hidden */
  10989. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10990. /** @hidden */
  10991. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10992. }
  10993. }
  10994. declare module BABYLON {
  10995. /**
  10996. * Groups all the scene component constants in one place to ease maintenance.
  10997. * @hidden
  10998. */
  10999. export class SceneComponentConstants {
  11000. static readonly NAME_EFFECTLAYER: string;
  11001. static readonly NAME_LAYER: string;
  11002. static readonly NAME_LENSFLARESYSTEM: string;
  11003. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11004. static readonly NAME_PARTICLESYSTEM: string;
  11005. static readonly NAME_GAMEPAD: string;
  11006. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11007. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11008. static readonly NAME_DEPTHRENDERER: string;
  11009. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11010. static readonly NAME_SPRITE: string;
  11011. static readonly NAME_OUTLINERENDERER: string;
  11012. static readonly NAME_PROCEDURALTEXTURE: string;
  11013. static readonly NAME_SHADOWGENERATOR: string;
  11014. static readonly NAME_OCTREE: string;
  11015. static readonly NAME_PHYSICSENGINE: string;
  11016. static readonly NAME_AUDIO: string;
  11017. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11018. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11019. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11020. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11021. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11022. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11023. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11024. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11025. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11026. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11027. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11028. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11029. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11030. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11031. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11032. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11033. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11034. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11035. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11036. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11037. static readonly STEP_AFTERRENDER_AUDIO: number;
  11038. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11039. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11040. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11041. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11042. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11043. static readonly STEP_POINTERMOVE_SPRITE: number;
  11044. static readonly STEP_POINTERDOWN_SPRITE: number;
  11045. static readonly STEP_POINTERUP_SPRITE: number;
  11046. }
  11047. /**
  11048. * This represents a scene component.
  11049. *
  11050. * This is used to decouple the dependency the scene is having on the different workloads like
  11051. * layers, post processes...
  11052. */
  11053. export interface ISceneComponent {
  11054. /**
  11055. * The name of the component. Each component must have a unique name.
  11056. */
  11057. name: string;
  11058. /**
  11059. * The scene the component belongs to.
  11060. */
  11061. scene: Scene;
  11062. /**
  11063. * Register the component to one instance of a scene.
  11064. */
  11065. register(): void;
  11066. /**
  11067. * Rebuilds the elements related to this component in case of
  11068. * context lost for instance.
  11069. */
  11070. rebuild(): void;
  11071. /**
  11072. * Disposes the component and the associated ressources.
  11073. */
  11074. dispose(): void;
  11075. }
  11076. /**
  11077. * This represents a SERIALIZABLE scene component.
  11078. *
  11079. * This extends Scene Component to add Serialization methods on top.
  11080. */
  11081. export interface ISceneSerializableComponent extends ISceneComponent {
  11082. /**
  11083. * Adds all the elements from the container to the scene
  11084. * @param container the container holding the elements
  11085. */
  11086. addFromContainer(container: AbstractScene): void;
  11087. /**
  11088. * Removes all the elements in the container from the scene
  11089. * @param container contains the elements to remove
  11090. * @param dispose if the removed element should be disposed (default: false)
  11091. */
  11092. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11093. /**
  11094. * Serializes the component data to the specified json object
  11095. * @param serializationObject The object to serialize to
  11096. */
  11097. serialize(serializationObject: any): void;
  11098. }
  11099. /**
  11100. * Strong typing of a Mesh related stage step action
  11101. */
  11102. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11103. /**
  11104. * Strong typing of a Evaluate Sub Mesh related stage step action
  11105. */
  11106. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11107. /**
  11108. * Strong typing of a Active Mesh related stage step action
  11109. */
  11110. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11111. /**
  11112. * Strong typing of a Camera related stage step action
  11113. */
  11114. export type CameraStageAction = (camera: Camera) => void;
  11115. /**
  11116. * Strong typing of a Camera Frame buffer related stage step action
  11117. */
  11118. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11119. /**
  11120. * Strong typing of a Render Target related stage step action
  11121. */
  11122. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11123. /**
  11124. * Strong typing of a RenderingGroup related stage step action
  11125. */
  11126. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11127. /**
  11128. * Strong typing of a Mesh Render related stage step action
  11129. */
  11130. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11131. /**
  11132. * Strong typing of a simple stage step action
  11133. */
  11134. export type SimpleStageAction = () => void;
  11135. /**
  11136. * Strong typing of a render target action.
  11137. */
  11138. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11139. /**
  11140. * Strong typing of a pointer move action.
  11141. */
  11142. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11143. /**
  11144. * Strong typing of a pointer up/down action.
  11145. */
  11146. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11147. /**
  11148. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11149. * @hidden
  11150. */
  11151. export class Stage<T extends Function> extends Array<{
  11152. index: number;
  11153. component: ISceneComponent;
  11154. action: T;
  11155. }> {
  11156. /**
  11157. * Hide ctor from the rest of the world.
  11158. * @param items The items to add.
  11159. */
  11160. private constructor();
  11161. /**
  11162. * Creates a new Stage.
  11163. * @returns A new instance of a Stage
  11164. */
  11165. static Create<T extends Function>(): Stage<T>;
  11166. /**
  11167. * Registers a step in an ordered way in the targeted stage.
  11168. * @param index Defines the position to register the step in
  11169. * @param component Defines the component attached to the step
  11170. * @param action Defines the action to launch during the step
  11171. */
  11172. registerStep(index: number, component: ISceneComponent, action: T): void;
  11173. /**
  11174. * Clears all the steps from the stage.
  11175. */
  11176. clear(): void;
  11177. }
  11178. }
  11179. declare module BABYLON {
  11180. interface Scene {
  11181. /** @hidden */
  11182. _pointerOverSprite: Nullable<Sprite>;
  11183. /** @hidden */
  11184. _pickedDownSprite: Nullable<Sprite>;
  11185. /** @hidden */
  11186. _tempSpritePickingRay: Nullable<Ray>;
  11187. /**
  11188. * All of the sprite managers added to this scene
  11189. * @see http://doc.babylonjs.com/babylon101/sprites
  11190. */
  11191. spriteManagers: Array<ISpriteManager>;
  11192. /**
  11193. * An event triggered when sprites rendering is about to start
  11194. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11195. */
  11196. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11197. /**
  11198. * An event triggered when sprites rendering is done
  11199. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11200. */
  11201. onAfterSpritesRenderingObservable: Observable<Scene>;
  11202. /** @hidden */
  11203. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11204. /** Launch a ray to try to pick a sprite in the scene
  11205. * @param x position on screen
  11206. * @param y position on screen
  11207. * @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
  11208. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11209. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11210. * @returns a PickingInfo
  11211. */
  11212. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11213. /** Use the given ray to pick a sprite in the scene
  11214. * @param ray The ray (in world space) to use to pick meshes
  11215. * @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
  11216. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11217. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11218. * @returns a PickingInfo
  11219. */
  11220. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11221. /** @hidden */
  11222. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11223. /** Launch a ray to try to pick sprites in the scene
  11224. * @param x position on screen
  11225. * @param y position on screen
  11226. * @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
  11227. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11228. * @returns a PickingInfo array
  11229. */
  11230. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11231. /** Use the given ray to pick sprites in the scene
  11232. * @param ray The ray (in world space) to use to pick meshes
  11233. * @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
  11234. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11235. * @returns a PickingInfo array
  11236. */
  11237. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11238. /**
  11239. * Force the sprite under the pointer
  11240. * @param sprite defines the sprite to use
  11241. */
  11242. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11243. /**
  11244. * Gets the sprite under the pointer
  11245. * @returns a Sprite or null if no sprite is under the pointer
  11246. */
  11247. getPointerOverSprite(): Nullable<Sprite>;
  11248. }
  11249. /**
  11250. * Defines the sprite scene component responsible to manage sprites
  11251. * in a given scene.
  11252. */
  11253. export class SpriteSceneComponent implements ISceneComponent {
  11254. /**
  11255. * The component name helpfull to identify the component in the list of scene components.
  11256. */
  11257. readonly name: string;
  11258. /**
  11259. * The scene the component belongs to.
  11260. */
  11261. scene: Scene;
  11262. /** @hidden */
  11263. private _spritePredicate;
  11264. /**
  11265. * Creates a new instance of the component for the given scene
  11266. * @param scene Defines the scene to register the component in
  11267. */
  11268. constructor(scene: Scene);
  11269. /**
  11270. * Registers the component in a given scene
  11271. */
  11272. register(): void;
  11273. /**
  11274. * Rebuilds the elements related to this component in case of
  11275. * context lost for instance.
  11276. */
  11277. rebuild(): void;
  11278. /**
  11279. * Disposes the component and the associated ressources.
  11280. */
  11281. dispose(): void;
  11282. private _pickSpriteButKeepRay;
  11283. private _pointerMove;
  11284. private _pointerDown;
  11285. private _pointerUp;
  11286. }
  11287. }
  11288. declare module BABYLON {
  11289. /** @hidden */
  11290. export var fogFragmentDeclaration: {
  11291. name: string;
  11292. shader: string;
  11293. };
  11294. }
  11295. declare module BABYLON {
  11296. /** @hidden */
  11297. export var fogFragment: {
  11298. name: string;
  11299. shader: string;
  11300. };
  11301. }
  11302. declare module BABYLON {
  11303. /** @hidden */
  11304. export var spritesPixelShader: {
  11305. name: string;
  11306. shader: string;
  11307. };
  11308. }
  11309. declare module BABYLON {
  11310. /** @hidden */
  11311. export var fogVertexDeclaration: {
  11312. name: string;
  11313. shader: string;
  11314. };
  11315. }
  11316. declare module BABYLON {
  11317. /** @hidden */
  11318. export var spritesVertexShader: {
  11319. name: string;
  11320. shader: string;
  11321. };
  11322. }
  11323. declare module BABYLON {
  11324. /**
  11325. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11326. */
  11327. export interface ISpriteManager extends IDisposable {
  11328. /**
  11329. * Restricts the camera to viewing objects with the same layerMask.
  11330. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11331. */
  11332. layerMask: number;
  11333. /**
  11334. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11335. */
  11336. isPickable: boolean;
  11337. /**
  11338. * Specifies the rendering group id for this mesh (0 by default)
  11339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11340. */
  11341. renderingGroupId: number;
  11342. /**
  11343. * Defines the list of sprites managed by the manager.
  11344. */
  11345. sprites: Array<Sprite>;
  11346. /**
  11347. * Tests the intersection of a sprite with a specific ray.
  11348. * @param ray The ray we are sending to test the collision
  11349. * @param camera The camera space we are sending rays in
  11350. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11351. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11352. * @returns picking info or null.
  11353. */
  11354. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11355. /**
  11356. * Intersects the sprites with a ray
  11357. * @param ray defines the ray to intersect with
  11358. * @param camera defines the current active camera
  11359. * @param predicate defines a predicate used to select candidate sprites
  11360. * @returns null if no hit or a PickingInfo array
  11361. */
  11362. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11363. /**
  11364. * Renders the list of sprites on screen.
  11365. */
  11366. render(): void;
  11367. }
  11368. /**
  11369. * Class used to manage multiple sprites on the same spritesheet
  11370. * @see http://doc.babylonjs.com/babylon101/sprites
  11371. */
  11372. export class SpriteManager implements ISpriteManager {
  11373. /** defines the manager's name */
  11374. name: string;
  11375. /** Gets the list of sprites */
  11376. sprites: Sprite[];
  11377. /** Gets or sets the rendering group id (0 by default) */
  11378. renderingGroupId: number;
  11379. /** Gets or sets camera layer mask */
  11380. layerMask: number;
  11381. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11382. fogEnabled: boolean;
  11383. /** Gets or sets a boolean indicating if the sprites are pickable */
  11384. isPickable: boolean;
  11385. /** Defines the default width of a cell in the spritesheet */
  11386. cellWidth: number;
  11387. /** Defines the default height of a cell in the spritesheet */
  11388. cellHeight: number;
  11389. /** Associative array from JSON sprite data file */
  11390. private _cellData;
  11391. /** Array of sprite names from JSON sprite data file */
  11392. private _spriteMap;
  11393. /** True when packed cell data from JSON file is ready*/
  11394. private _packedAndReady;
  11395. /**
  11396. * An event triggered when the manager is disposed.
  11397. */
  11398. onDisposeObservable: Observable<SpriteManager>;
  11399. private _onDisposeObserver;
  11400. /**
  11401. * Callback called when the manager is disposed
  11402. */
  11403. onDispose: () => void;
  11404. private _capacity;
  11405. private _fromPacked;
  11406. private _spriteTexture;
  11407. private _epsilon;
  11408. private _scene;
  11409. private _vertexData;
  11410. private _buffer;
  11411. private _vertexBuffers;
  11412. private _indexBuffer;
  11413. private _effectBase;
  11414. private _effectFog;
  11415. /**
  11416. * Gets or sets the spritesheet texture
  11417. */
  11418. texture: Texture;
  11419. /**
  11420. * Creates a new sprite manager
  11421. * @param name defines the manager's name
  11422. * @param imgUrl defines the sprite sheet url
  11423. * @param capacity defines the maximum allowed number of sprites
  11424. * @param cellSize defines the size of a sprite cell
  11425. * @param scene defines the hosting scene
  11426. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11427. * @param samplingMode defines the smapling mode to use with spritesheet
  11428. * @param fromPacked set to false; do not alter
  11429. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11430. */
  11431. constructor(
  11432. /** defines the manager's name */
  11433. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11434. private _makePacked;
  11435. private _appendSpriteVertex;
  11436. /**
  11437. * Intersects the sprites with a ray
  11438. * @param ray defines the ray to intersect with
  11439. * @param camera defines the current active camera
  11440. * @param predicate defines a predicate used to select candidate sprites
  11441. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11442. * @returns null if no hit or a PickingInfo
  11443. */
  11444. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11445. /**
  11446. * Intersects the sprites with a ray
  11447. * @param ray defines the ray to intersect with
  11448. * @param camera defines the current active camera
  11449. * @param predicate defines a predicate used to select candidate sprites
  11450. * @returns null if no hit or a PickingInfo array
  11451. */
  11452. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11453. /**
  11454. * Render all child sprites
  11455. */
  11456. render(): void;
  11457. /**
  11458. * Release associated resources
  11459. */
  11460. dispose(): void;
  11461. }
  11462. }
  11463. declare module BABYLON {
  11464. /**
  11465. * Class used to represent a sprite
  11466. * @see http://doc.babylonjs.com/babylon101/sprites
  11467. */
  11468. export class Sprite {
  11469. /** defines the name */
  11470. name: string;
  11471. /** Gets or sets the current world position */
  11472. position: Vector3;
  11473. /** Gets or sets the main color */
  11474. color: Color4;
  11475. /** Gets or sets the width */
  11476. width: number;
  11477. /** Gets or sets the height */
  11478. height: number;
  11479. /** Gets or sets rotation angle */
  11480. angle: number;
  11481. /** Gets or sets the cell index in the sprite sheet */
  11482. cellIndex: number;
  11483. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11484. cellRef: string;
  11485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11486. invertU: number;
  11487. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11488. invertV: number;
  11489. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11490. disposeWhenFinishedAnimating: boolean;
  11491. /** Gets the list of attached animations */
  11492. animations: Animation[];
  11493. /** Gets or sets a boolean indicating if the sprite can be picked */
  11494. isPickable: boolean;
  11495. /**
  11496. * Gets or sets the associated action manager
  11497. */
  11498. actionManager: Nullable<ActionManager>;
  11499. private _animationStarted;
  11500. private _loopAnimation;
  11501. private _fromIndex;
  11502. private _toIndex;
  11503. private _delay;
  11504. private _direction;
  11505. private _manager;
  11506. private _time;
  11507. private _onAnimationEnd;
  11508. /**
  11509. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11510. */
  11511. isVisible: boolean;
  11512. /**
  11513. * Gets or sets the sprite size
  11514. */
  11515. size: number;
  11516. /**
  11517. * Creates a new Sprite
  11518. * @param name defines the name
  11519. * @param manager defines the manager
  11520. */
  11521. constructor(
  11522. /** defines the name */
  11523. name: string, manager: ISpriteManager);
  11524. /**
  11525. * Starts an animation
  11526. * @param from defines the initial key
  11527. * @param to defines the end key
  11528. * @param loop defines if the animation must loop
  11529. * @param delay defines the start delay (in ms)
  11530. * @param onAnimationEnd defines a callback to call when animation ends
  11531. */
  11532. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11533. /** Stops current animation (if any) */
  11534. stopAnimation(): void;
  11535. /** @hidden */
  11536. _animate(deltaTime: number): void;
  11537. /** Release associated resources */
  11538. dispose(): void;
  11539. }
  11540. }
  11541. declare module BABYLON {
  11542. /**
  11543. * Information about the result of picking within a scene
  11544. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11545. */
  11546. export class PickingInfo {
  11547. /** @hidden */
  11548. _pickingUnavailable: boolean;
  11549. /**
  11550. * If the pick collided with an object
  11551. */
  11552. hit: boolean;
  11553. /**
  11554. * Distance away where the pick collided
  11555. */
  11556. distance: number;
  11557. /**
  11558. * The location of pick collision
  11559. */
  11560. pickedPoint: Nullable<Vector3>;
  11561. /**
  11562. * The mesh corresponding the the pick collision
  11563. */
  11564. pickedMesh: Nullable<AbstractMesh>;
  11565. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11566. bu: number;
  11567. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11568. bv: number;
  11569. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11570. faceId: number;
  11571. /** Id of the the submesh that was picked */
  11572. subMeshId: number;
  11573. /** If a sprite was picked, this will be the sprite the pick collided with */
  11574. pickedSprite: Nullable<Sprite>;
  11575. /**
  11576. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11577. */
  11578. originMesh: Nullable<AbstractMesh>;
  11579. /**
  11580. * The ray that was used to perform the picking.
  11581. */
  11582. ray: Nullable<Ray>;
  11583. /**
  11584. * Gets the normal correspodning to the face the pick collided with
  11585. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11586. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11587. * @returns The normal correspodning to the face the pick collided with
  11588. */
  11589. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11590. /**
  11591. * Gets the texture coordinates of where the pick occured
  11592. * @returns the vector containing the coordnates of the texture
  11593. */
  11594. getTextureCoordinates(): Nullable<Vector2>;
  11595. }
  11596. }
  11597. declare module BABYLON {
  11598. /**
  11599. * Gather the list of pointer event types as constants.
  11600. */
  11601. export class PointerEventTypes {
  11602. /**
  11603. * 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.
  11604. */
  11605. static readonly POINTERDOWN: number;
  11606. /**
  11607. * The pointerup event is fired when a pointer is no longer active.
  11608. */
  11609. static readonly POINTERUP: number;
  11610. /**
  11611. * The pointermove event is fired when a pointer changes coordinates.
  11612. */
  11613. static readonly POINTERMOVE: number;
  11614. /**
  11615. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11616. */
  11617. static readonly POINTERWHEEL: number;
  11618. /**
  11619. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11620. */
  11621. static readonly POINTERPICK: number;
  11622. /**
  11623. * The pointertap event is fired when a the object has been touched and released without drag.
  11624. */
  11625. static readonly POINTERTAP: number;
  11626. /**
  11627. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11628. */
  11629. static readonly POINTERDOUBLETAP: number;
  11630. }
  11631. /**
  11632. * Base class of pointer info types.
  11633. */
  11634. export class PointerInfoBase {
  11635. /**
  11636. * Defines the type of event (PointerEventTypes)
  11637. */
  11638. type: number;
  11639. /**
  11640. * Defines the related dom event
  11641. */
  11642. event: PointerEvent | MouseWheelEvent;
  11643. /**
  11644. * Instantiates the base class of pointers info.
  11645. * @param type Defines the type of event (PointerEventTypes)
  11646. * @param event Defines the related dom event
  11647. */
  11648. constructor(
  11649. /**
  11650. * Defines the type of event (PointerEventTypes)
  11651. */
  11652. type: number,
  11653. /**
  11654. * Defines the related dom event
  11655. */
  11656. event: PointerEvent | MouseWheelEvent);
  11657. }
  11658. /**
  11659. * This class is used to store pointer related info for the onPrePointerObservable event.
  11660. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11661. */
  11662. export class PointerInfoPre extends PointerInfoBase {
  11663. /**
  11664. * Ray from a pointer if availible (eg. 6dof controller)
  11665. */
  11666. ray: Nullable<Ray>;
  11667. /**
  11668. * Defines the local position of the pointer on the canvas.
  11669. */
  11670. localPosition: Vector2;
  11671. /**
  11672. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11673. */
  11674. skipOnPointerObservable: boolean;
  11675. /**
  11676. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11677. * @param type Defines the type of event (PointerEventTypes)
  11678. * @param event Defines the related dom event
  11679. * @param localX Defines the local x coordinates of the pointer when the event occured
  11680. * @param localY Defines the local y coordinates of the pointer when the event occured
  11681. */
  11682. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11683. }
  11684. /**
  11685. * This type contains all the data related to a pointer event in Babylon.js.
  11686. * 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.
  11687. */
  11688. export class PointerInfo extends PointerInfoBase {
  11689. /**
  11690. * Defines the picking info associated to the info (if any)\
  11691. */
  11692. pickInfo: Nullable<PickingInfo>;
  11693. /**
  11694. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11695. * @param type Defines the type of event (PointerEventTypes)
  11696. * @param event Defines the related dom event
  11697. * @param pickInfo Defines the picking info associated to the info (if any)\
  11698. */
  11699. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11700. /**
  11701. * Defines the picking info associated to the info (if any)\
  11702. */
  11703. pickInfo: Nullable<PickingInfo>);
  11704. }
  11705. /**
  11706. * Data relating to a touch event on the screen.
  11707. */
  11708. export interface PointerTouch {
  11709. /**
  11710. * X coordinate of touch.
  11711. */
  11712. x: number;
  11713. /**
  11714. * Y coordinate of touch.
  11715. */
  11716. y: number;
  11717. /**
  11718. * Id of touch. Unique for each finger.
  11719. */
  11720. pointerId: number;
  11721. /**
  11722. * Event type passed from DOM.
  11723. */
  11724. type: any;
  11725. }
  11726. }
  11727. declare module BABYLON {
  11728. /**
  11729. * Manage the mouse inputs to control the movement of a free camera.
  11730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11731. */
  11732. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11733. /**
  11734. * Define if touch is enabled in the mouse input
  11735. */
  11736. touchEnabled: boolean;
  11737. /**
  11738. * Defines the camera the input is attached to.
  11739. */
  11740. camera: FreeCamera;
  11741. /**
  11742. * Defines the buttons associated with the input to handle camera move.
  11743. */
  11744. buttons: number[];
  11745. /**
  11746. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11747. */
  11748. angularSensibility: number;
  11749. private _pointerInput;
  11750. private _onMouseMove;
  11751. private _observer;
  11752. private previousPosition;
  11753. /**
  11754. * Observable for when a pointer move event occurs containing the move offset
  11755. */
  11756. onPointerMovedObservable: Observable<{
  11757. offsetX: number;
  11758. offsetY: number;
  11759. }>;
  11760. /**
  11761. * @hidden
  11762. * If the camera should be rotated automatically based on pointer movement
  11763. */
  11764. _allowCameraRotation: boolean;
  11765. /**
  11766. * Manage the mouse inputs to control the movement of a free camera.
  11767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11768. * @param touchEnabled Defines if touch is enabled or not
  11769. */
  11770. constructor(
  11771. /**
  11772. * Define if touch is enabled in the mouse input
  11773. */
  11774. touchEnabled?: boolean);
  11775. /**
  11776. * Attach the input controls to a specific dom element to get the input from.
  11777. * @param element Defines the element the controls should be listened from
  11778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11779. */
  11780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11781. /**
  11782. * Called on JS contextmenu event.
  11783. * Override this method to provide functionality.
  11784. */
  11785. protected onContextMenu(evt: PointerEvent): void;
  11786. /**
  11787. * Detach the current controls from the specified dom element.
  11788. * @param element Defines the element to stop listening the inputs from
  11789. */
  11790. detachControl(element: Nullable<HTMLElement>): void;
  11791. /**
  11792. * Gets the class name of the current intput.
  11793. * @returns the class name
  11794. */
  11795. getClassName(): string;
  11796. /**
  11797. * Get the friendly name associated with the input class.
  11798. * @returns the input friendly name
  11799. */
  11800. getSimpleName(): string;
  11801. }
  11802. }
  11803. declare module BABYLON {
  11804. /**
  11805. * Manage the touch inputs to control the movement of a free camera.
  11806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11807. */
  11808. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11809. /**
  11810. * Defines the camera the input is attached to.
  11811. */
  11812. camera: FreeCamera;
  11813. /**
  11814. * Defines the touch sensibility for rotation.
  11815. * The higher the faster.
  11816. */
  11817. touchAngularSensibility: number;
  11818. /**
  11819. * Defines the touch sensibility for move.
  11820. * The higher the faster.
  11821. */
  11822. touchMoveSensibility: number;
  11823. private _offsetX;
  11824. private _offsetY;
  11825. private _pointerPressed;
  11826. private _pointerInput;
  11827. private _observer;
  11828. private _onLostFocus;
  11829. /**
  11830. * Attach the input controls to a specific dom element to get the input from.
  11831. * @param element Defines the element the controls should be listened from
  11832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11833. */
  11834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11835. /**
  11836. * Detach the current controls from the specified dom element.
  11837. * @param element Defines the element to stop listening the inputs from
  11838. */
  11839. detachControl(element: Nullable<HTMLElement>): void;
  11840. /**
  11841. * Update the current camera state depending on the inputs that have been used this frame.
  11842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11843. */
  11844. checkInputs(): void;
  11845. /**
  11846. * Gets the class name of the current intput.
  11847. * @returns the class name
  11848. */
  11849. getClassName(): string;
  11850. /**
  11851. * Get the friendly name associated with the input class.
  11852. * @returns the input friendly name
  11853. */
  11854. getSimpleName(): string;
  11855. }
  11856. }
  11857. declare module BABYLON {
  11858. /**
  11859. * Default Inputs manager for the FreeCamera.
  11860. * It groups all the default supported inputs for ease of use.
  11861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11862. */
  11863. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11864. /**
  11865. * @hidden
  11866. */
  11867. _mouseInput: Nullable<FreeCameraMouseInput>;
  11868. /**
  11869. * Instantiates a new FreeCameraInputsManager.
  11870. * @param camera Defines the camera the inputs belong to
  11871. */
  11872. constructor(camera: FreeCamera);
  11873. /**
  11874. * Add keyboard input support to the input manager.
  11875. * @returns the current input manager
  11876. */
  11877. addKeyboard(): FreeCameraInputsManager;
  11878. /**
  11879. * Add mouse input support to the input manager.
  11880. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11881. * @returns the current input manager
  11882. */
  11883. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11884. /**
  11885. * Removes the mouse input support from the manager
  11886. * @returns the current input manager
  11887. */
  11888. removeMouse(): FreeCameraInputsManager;
  11889. /**
  11890. * Add touch input support to the input manager.
  11891. * @returns the current input manager
  11892. */
  11893. addTouch(): FreeCameraInputsManager;
  11894. /**
  11895. * Remove all attached input methods from a camera
  11896. */
  11897. clear(): void;
  11898. }
  11899. }
  11900. declare module BABYLON {
  11901. /**
  11902. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11903. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11904. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11905. */
  11906. export class FreeCamera extends TargetCamera {
  11907. /**
  11908. * Define the collision ellipsoid of the camera.
  11909. * This is helpful to simulate a camera body like the player body around the camera
  11910. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11911. */
  11912. ellipsoid: Vector3;
  11913. /**
  11914. * Define an offset for the position of the ellipsoid around the camera.
  11915. * This can be helpful to determine the center of the body near the gravity center of the body
  11916. * instead of its head.
  11917. */
  11918. ellipsoidOffset: Vector3;
  11919. /**
  11920. * Enable or disable collisions of the camera with the rest of the scene objects.
  11921. */
  11922. checkCollisions: boolean;
  11923. /**
  11924. * Enable or disable gravity on the camera.
  11925. */
  11926. applyGravity: boolean;
  11927. /**
  11928. * Define the input manager associated to the camera.
  11929. */
  11930. inputs: FreeCameraInputsManager;
  11931. /**
  11932. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11933. * Higher values reduce sensitivity.
  11934. */
  11935. /**
  11936. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11937. * Higher values reduce sensitivity.
  11938. */
  11939. angularSensibility: number;
  11940. /**
  11941. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11942. */
  11943. keysUp: number[];
  11944. /**
  11945. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11946. */
  11947. keysDown: number[];
  11948. /**
  11949. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11950. */
  11951. keysLeft: number[];
  11952. /**
  11953. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11954. */
  11955. keysRight: number[];
  11956. /**
  11957. * Event raised when the camera collide with a mesh in the scene.
  11958. */
  11959. onCollide: (collidedMesh: AbstractMesh) => void;
  11960. private _collider;
  11961. private _needMoveForGravity;
  11962. private _oldPosition;
  11963. private _diffPosition;
  11964. private _newPosition;
  11965. /** @hidden */
  11966. _localDirection: Vector3;
  11967. /** @hidden */
  11968. _transformedDirection: Vector3;
  11969. /**
  11970. * Instantiates a Free Camera.
  11971. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11972. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11974. * @param name Define the name of the camera in the scene
  11975. * @param position Define the start position of the camera in the scene
  11976. * @param scene Define the scene the camera belongs to
  11977. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11978. */
  11979. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11980. /**
  11981. * Attached controls to the current camera.
  11982. * @param element Defines the element the controls should be listened from
  11983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11984. */
  11985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11986. /**
  11987. * Detach the current controls from the camera.
  11988. * The camera will stop reacting to inputs.
  11989. * @param element Defines the element to stop listening the inputs from
  11990. */
  11991. detachControl(element: HTMLElement): void;
  11992. private _collisionMask;
  11993. /**
  11994. * Define a collision mask to limit the list of object the camera can collide with
  11995. */
  11996. collisionMask: number;
  11997. /** @hidden */
  11998. _collideWithWorld(displacement: Vector3): void;
  11999. private _onCollisionPositionChange;
  12000. /** @hidden */
  12001. _checkInputs(): void;
  12002. /** @hidden */
  12003. _decideIfNeedsToMove(): boolean;
  12004. /** @hidden */
  12005. _updatePosition(): void;
  12006. /**
  12007. * Destroy the camera and release the current resources hold by it.
  12008. */
  12009. dispose(): void;
  12010. /**
  12011. * Gets the current object class name.
  12012. * @return the class name
  12013. */
  12014. getClassName(): string;
  12015. }
  12016. }
  12017. declare module BABYLON {
  12018. /**
  12019. * Represents a gamepad control stick position
  12020. */
  12021. export class StickValues {
  12022. /**
  12023. * The x component of the control stick
  12024. */
  12025. x: number;
  12026. /**
  12027. * The y component of the control stick
  12028. */
  12029. y: number;
  12030. /**
  12031. * Initializes the gamepad x and y control stick values
  12032. * @param x The x component of the gamepad control stick value
  12033. * @param y The y component of the gamepad control stick value
  12034. */
  12035. constructor(
  12036. /**
  12037. * The x component of the control stick
  12038. */
  12039. x: number,
  12040. /**
  12041. * The y component of the control stick
  12042. */
  12043. y: number);
  12044. }
  12045. /**
  12046. * An interface which manages callbacks for gamepad button changes
  12047. */
  12048. export interface GamepadButtonChanges {
  12049. /**
  12050. * Called when a gamepad has been changed
  12051. */
  12052. changed: boolean;
  12053. /**
  12054. * Called when a gamepad press event has been triggered
  12055. */
  12056. pressChanged: boolean;
  12057. /**
  12058. * Called when a touch event has been triggered
  12059. */
  12060. touchChanged: boolean;
  12061. /**
  12062. * Called when a value has changed
  12063. */
  12064. valueChanged: boolean;
  12065. }
  12066. /**
  12067. * Represents a gamepad
  12068. */
  12069. export class Gamepad {
  12070. /**
  12071. * The id of the gamepad
  12072. */
  12073. id: string;
  12074. /**
  12075. * The index of the gamepad
  12076. */
  12077. index: number;
  12078. /**
  12079. * The browser gamepad
  12080. */
  12081. browserGamepad: any;
  12082. /**
  12083. * Specifies what type of gamepad this represents
  12084. */
  12085. type: number;
  12086. private _leftStick;
  12087. private _rightStick;
  12088. /** @hidden */
  12089. _isConnected: boolean;
  12090. private _leftStickAxisX;
  12091. private _leftStickAxisY;
  12092. private _rightStickAxisX;
  12093. private _rightStickAxisY;
  12094. /**
  12095. * Triggered when the left control stick has been changed
  12096. */
  12097. private _onleftstickchanged;
  12098. /**
  12099. * Triggered when the right control stick has been changed
  12100. */
  12101. private _onrightstickchanged;
  12102. /**
  12103. * Represents a gamepad controller
  12104. */
  12105. static GAMEPAD: number;
  12106. /**
  12107. * Represents a generic controller
  12108. */
  12109. static GENERIC: number;
  12110. /**
  12111. * Represents an XBox controller
  12112. */
  12113. static XBOX: number;
  12114. /**
  12115. * Represents a pose-enabled controller
  12116. */
  12117. static POSE_ENABLED: number;
  12118. /**
  12119. * Represents an Dual Shock controller
  12120. */
  12121. static DUALSHOCK: number;
  12122. /**
  12123. * Specifies whether the left control stick should be Y-inverted
  12124. */
  12125. protected _invertLeftStickY: boolean;
  12126. /**
  12127. * Specifies if the gamepad has been connected
  12128. */
  12129. readonly isConnected: boolean;
  12130. /**
  12131. * Initializes the gamepad
  12132. * @param id The id of the gamepad
  12133. * @param index The index of the gamepad
  12134. * @param browserGamepad The browser gamepad
  12135. * @param leftStickX The x component of the left joystick
  12136. * @param leftStickY The y component of the left joystick
  12137. * @param rightStickX The x component of the right joystick
  12138. * @param rightStickY The y component of the right joystick
  12139. */
  12140. constructor(
  12141. /**
  12142. * The id of the gamepad
  12143. */
  12144. id: string,
  12145. /**
  12146. * The index of the gamepad
  12147. */
  12148. index: number,
  12149. /**
  12150. * The browser gamepad
  12151. */
  12152. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12153. /**
  12154. * Callback triggered when the left joystick has changed
  12155. * @param callback
  12156. */
  12157. onleftstickchanged(callback: (values: StickValues) => void): void;
  12158. /**
  12159. * Callback triggered when the right joystick has changed
  12160. * @param callback
  12161. */
  12162. onrightstickchanged(callback: (values: StickValues) => void): void;
  12163. /**
  12164. * Gets the left joystick
  12165. */
  12166. /**
  12167. * Sets the left joystick values
  12168. */
  12169. leftStick: StickValues;
  12170. /**
  12171. * Gets the right joystick
  12172. */
  12173. /**
  12174. * Sets the right joystick value
  12175. */
  12176. rightStick: StickValues;
  12177. /**
  12178. * Updates the gamepad joystick positions
  12179. */
  12180. update(): void;
  12181. /**
  12182. * Disposes the gamepad
  12183. */
  12184. dispose(): void;
  12185. }
  12186. /**
  12187. * Represents a generic gamepad
  12188. */
  12189. export class GenericPad extends Gamepad {
  12190. private _buttons;
  12191. private _onbuttondown;
  12192. private _onbuttonup;
  12193. /**
  12194. * Observable triggered when a button has been pressed
  12195. */
  12196. onButtonDownObservable: Observable<number>;
  12197. /**
  12198. * Observable triggered when a button has been released
  12199. */
  12200. onButtonUpObservable: Observable<number>;
  12201. /**
  12202. * Callback triggered when a button has been pressed
  12203. * @param callback Called when a button has been pressed
  12204. */
  12205. onbuttondown(callback: (buttonPressed: number) => void): void;
  12206. /**
  12207. * Callback triggered when a button has been released
  12208. * @param callback Called when a button has been released
  12209. */
  12210. onbuttonup(callback: (buttonReleased: number) => void): void;
  12211. /**
  12212. * Initializes the generic gamepad
  12213. * @param id The id of the generic gamepad
  12214. * @param index The index of the generic gamepad
  12215. * @param browserGamepad The browser gamepad
  12216. */
  12217. constructor(id: string, index: number, browserGamepad: any);
  12218. private _setButtonValue;
  12219. /**
  12220. * Updates the generic gamepad
  12221. */
  12222. update(): void;
  12223. /**
  12224. * Disposes the generic gamepad
  12225. */
  12226. dispose(): void;
  12227. }
  12228. }
  12229. declare module BABYLON {
  12230. interface Engine {
  12231. /**
  12232. * Creates a raw texture
  12233. * @param data defines the data to store in the texture
  12234. * @param width defines the width of the texture
  12235. * @param height defines the height of the texture
  12236. * @param format defines the format of the data
  12237. * @param generateMipMaps defines if the engine should generate the mip levels
  12238. * @param invertY defines if data must be stored with Y axis inverted
  12239. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12240. * @param compression defines the compression used (null by default)
  12241. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12242. * @returns the raw texture inside an InternalTexture
  12243. */
  12244. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12245. /**
  12246. * Update a raw texture
  12247. * @param texture defines the texture to update
  12248. * @param data defines the data to store in the texture
  12249. * @param format defines the format of the data
  12250. * @param invertY defines if data must be stored with Y axis inverted
  12251. */
  12252. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12253. /**
  12254. * Update a raw texture
  12255. * @param texture defines the texture to update
  12256. * @param data defines the data to store in the texture
  12257. * @param format defines the format of the data
  12258. * @param invertY defines if data must be stored with Y axis inverted
  12259. * @param compression defines the compression used (null by default)
  12260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12261. */
  12262. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12263. /**
  12264. * Creates a new raw cube texture
  12265. * @param data defines the array of data to use to create each face
  12266. * @param size defines the size of the textures
  12267. * @param format defines the format of the data
  12268. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12269. * @param generateMipMaps defines if the engine should generate the mip levels
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12272. * @param compression defines the compression used (null by default)
  12273. * @returns the cube texture as an InternalTexture
  12274. */
  12275. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12276. /**
  12277. * Update a raw cube texture
  12278. * @param texture defines the texture to udpdate
  12279. * @param data defines the data to store
  12280. * @param format defines the data format
  12281. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12282. * @param invertY defines if data must be stored with Y axis inverted
  12283. */
  12284. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12285. /**
  12286. * Update a raw cube texture
  12287. * @param texture defines the texture to udpdate
  12288. * @param data defines the data to store
  12289. * @param format defines the data format
  12290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12291. * @param invertY defines if data must be stored with Y axis inverted
  12292. * @param compression defines the compression used (null by default)
  12293. */
  12294. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12295. /**
  12296. * Update a raw cube texture
  12297. * @param texture defines the texture to udpdate
  12298. * @param data defines the data to store
  12299. * @param format defines the data format
  12300. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12301. * @param invertY defines if data must be stored with Y axis inverted
  12302. * @param compression defines the compression used (null by default)
  12303. * @param level defines which level of the texture to update
  12304. */
  12305. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12306. /**
  12307. * Creates a new raw cube texture from a specified url
  12308. * @param url defines the url where the data is located
  12309. * @param scene defines the current scene
  12310. * @param size defines the size of the textures
  12311. * @param format defines the format of the data
  12312. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12313. * @param noMipmap defines if the engine should avoid generating the mip levels
  12314. * @param callback defines a callback used to extract texture data from loaded data
  12315. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12316. * @param onLoad defines a callback called when texture is loaded
  12317. * @param onError defines a callback called if there is an error
  12318. * @returns the cube texture as an InternalTexture
  12319. */
  12320. 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;
  12321. /**
  12322. * Creates a new raw cube texture from a specified url
  12323. * @param url defines the url where the data is located
  12324. * @param scene defines the current scene
  12325. * @param size defines the size of the textures
  12326. * @param format defines the format of the data
  12327. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12328. * @param noMipmap defines if the engine should avoid generating the mip levels
  12329. * @param callback defines a callback used to extract texture data from loaded data
  12330. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12331. * @param onLoad defines a callback called when texture is loaded
  12332. * @param onError defines a callback called if there is an error
  12333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12334. * @param invertY defines if data must be stored with Y axis inverted
  12335. * @returns the cube texture as an InternalTexture
  12336. */
  12337. 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;
  12338. /**
  12339. * Creates a new raw 3D texture
  12340. * @param data defines the data used to create the texture
  12341. * @param width defines the width of the texture
  12342. * @param height defines the height of the texture
  12343. * @param depth defines the depth of the texture
  12344. * @param format defines the format of the texture
  12345. * @param generateMipMaps defines if the engine must generate mip levels
  12346. * @param invertY defines if data must be stored with Y axis inverted
  12347. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12348. * @param compression defines the compressed used (can be null)
  12349. * @param textureType defines the compressed used (can be null)
  12350. * @returns a new raw 3D texture (stored in an InternalTexture)
  12351. */
  12352. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12353. /**
  12354. * Update a raw 3D texture
  12355. * @param texture defines the texture to update
  12356. * @param data defines the data to store
  12357. * @param format defines the data format
  12358. * @param invertY defines if data must be stored with Y axis inverted
  12359. */
  12360. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12361. /**
  12362. * Update a raw 3D texture
  12363. * @param texture defines the texture to update
  12364. * @param data defines the data to store
  12365. * @param format defines the data format
  12366. * @param invertY defines if data must be stored with Y axis inverted
  12367. * @param compression defines the used compression (can be null)
  12368. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12369. */
  12370. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12371. }
  12372. }
  12373. declare module BABYLON {
  12374. /**
  12375. * Raw texture can help creating a texture directly from an array of data.
  12376. * This can be super useful if you either get the data from an uncompressed source or
  12377. * if you wish to create your texture pixel by pixel.
  12378. */
  12379. export class RawTexture extends Texture {
  12380. /**
  12381. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12382. */
  12383. format: number;
  12384. private _engine;
  12385. /**
  12386. * Instantiates a new RawTexture.
  12387. * Raw texture can help creating a texture directly from an array of data.
  12388. * This can be super useful if you either get the data from an uncompressed source or
  12389. * if you wish to create your texture pixel by pixel.
  12390. * @param data define the array of data to use to create the texture
  12391. * @param width define the width of the texture
  12392. * @param height define the height of the texture
  12393. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12394. * @param scene define the scene the texture belongs to
  12395. * @param generateMipMaps define whether mip maps should be generated or not
  12396. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12397. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12398. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12399. */
  12400. constructor(data: ArrayBufferView, width: number, height: number,
  12401. /**
  12402. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12403. */
  12404. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12405. /**
  12406. * Updates the texture underlying data.
  12407. * @param data Define the new data of the texture
  12408. */
  12409. update(data: ArrayBufferView): void;
  12410. /**
  12411. * Creates a luminance texture from some data.
  12412. * @param data Define the texture data
  12413. * @param width Define the width of the texture
  12414. * @param height Define the height of the texture
  12415. * @param scene Define the scene the texture belongs to
  12416. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12419. * @returns the luminance texture
  12420. */
  12421. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12422. /**
  12423. * Creates a luminance alpha texture from some data.
  12424. * @param data Define the texture data
  12425. * @param width Define the width of the texture
  12426. * @param height Define the height of the texture
  12427. * @param scene Define the scene the texture belongs to
  12428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @returns the luminance alpha texture
  12432. */
  12433. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12434. /**
  12435. * Creates an alpha texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @returns the alpha texture
  12444. */
  12445. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12446. /**
  12447. * Creates a RGB texture from some data.
  12448. * @param data Define the texture data
  12449. * @param width Define the width of the texture
  12450. * @param height Define the height of the texture
  12451. * @param scene Define the scene the texture belongs to
  12452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12455. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12456. * @returns the RGB alpha texture
  12457. */
  12458. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12459. /**
  12460. * Creates a RGBA texture from some data.
  12461. * @param data Define the texture data
  12462. * @param width Define the width of the texture
  12463. * @param height Define the height of the texture
  12464. * @param scene Define the scene the texture belongs to
  12465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12468. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12469. * @returns the RGBA texture
  12470. */
  12471. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12472. /**
  12473. * Creates a R texture from some data.
  12474. * @param data Define the texture data
  12475. * @param width Define the width of the texture
  12476. * @param height Define the height of the texture
  12477. * @param scene Define the scene the texture belongs to
  12478. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12481. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12482. * @returns the R texture
  12483. */
  12484. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12485. }
  12486. }
  12487. declare module BABYLON {
  12488. /**
  12489. * Interface for the size containing width and height
  12490. */
  12491. export interface ISize {
  12492. /**
  12493. * Width
  12494. */
  12495. width: number;
  12496. /**
  12497. * Heighht
  12498. */
  12499. height: number;
  12500. }
  12501. /**
  12502. * Size containing widht and height
  12503. */
  12504. export class Size implements ISize {
  12505. /**
  12506. * Width
  12507. */
  12508. width: number;
  12509. /**
  12510. * Height
  12511. */
  12512. height: number;
  12513. /**
  12514. * Creates a Size object from the given width and height (floats).
  12515. * @param width width of the new size
  12516. * @param height height of the new size
  12517. */
  12518. constructor(width: number, height: number);
  12519. /**
  12520. * Returns a string with the Size width and height
  12521. * @returns a string with the Size width and height
  12522. */
  12523. toString(): string;
  12524. /**
  12525. * "Size"
  12526. * @returns the string "Size"
  12527. */
  12528. getClassName(): string;
  12529. /**
  12530. * Returns the Size hash code.
  12531. * @returns a hash code for a unique width and height
  12532. */
  12533. getHashCode(): number;
  12534. /**
  12535. * Updates the current size from the given one.
  12536. * @param src the given size
  12537. */
  12538. copyFrom(src: Size): void;
  12539. /**
  12540. * Updates in place the current Size from the given floats.
  12541. * @param width width of the new size
  12542. * @param height height of the new size
  12543. * @returns the updated Size.
  12544. */
  12545. copyFromFloats(width: number, height: number): Size;
  12546. /**
  12547. * Updates in place the current Size from the given floats.
  12548. * @param width width to set
  12549. * @param height height to set
  12550. * @returns the updated Size.
  12551. */
  12552. set(width: number, height: number): Size;
  12553. /**
  12554. * Multiplies the width and height by numbers
  12555. * @param w factor to multiple the width by
  12556. * @param h factor to multiple the height by
  12557. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12558. */
  12559. multiplyByFloats(w: number, h: number): Size;
  12560. /**
  12561. * Clones the size
  12562. * @returns a new Size copied from the given one.
  12563. */
  12564. clone(): Size;
  12565. /**
  12566. * True if the current Size and the given one width and height are strictly equal.
  12567. * @param other the other size to compare against
  12568. * @returns True if the current Size and the given one width and height are strictly equal.
  12569. */
  12570. equals(other: Size): boolean;
  12571. /**
  12572. * The surface of the Size : width * height (float).
  12573. */
  12574. readonly surface: number;
  12575. /**
  12576. * Create a new size of zero
  12577. * @returns a new Size set to (0.0, 0.0)
  12578. */
  12579. static Zero(): Size;
  12580. /**
  12581. * Sums the width and height of two sizes
  12582. * @param otherSize size to add to this size
  12583. * @returns a new Size set as the addition result of the current Size and the given one.
  12584. */
  12585. add(otherSize: Size): Size;
  12586. /**
  12587. * Subtracts the width and height of two
  12588. * @param otherSize size to subtract to this size
  12589. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12590. */
  12591. subtract(otherSize: Size): Size;
  12592. /**
  12593. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12594. * @param start starting size to lerp between
  12595. * @param end end size to lerp between
  12596. * @param amount amount to lerp between the start and end values
  12597. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12598. */
  12599. static Lerp(start: Size, end: Size, amount: number): Size;
  12600. }
  12601. }
  12602. declare module BABYLON {
  12603. /**
  12604. * Defines a runtime animation
  12605. */
  12606. export class RuntimeAnimation {
  12607. private _events;
  12608. /**
  12609. * The current frame of the runtime animation
  12610. */
  12611. private _currentFrame;
  12612. /**
  12613. * The animation used by the runtime animation
  12614. */
  12615. private _animation;
  12616. /**
  12617. * The target of the runtime animation
  12618. */
  12619. private _target;
  12620. /**
  12621. * The initiating animatable
  12622. */
  12623. private _host;
  12624. /**
  12625. * The original value of the runtime animation
  12626. */
  12627. private _originalValue;
  12628. /**
  12629. * The original blend value of the runtime animation
  12630. */
  12631. private _originalBlendValue;
  12632. /**
  12633. * The offsets cache of the runtime animation
  12634. */
  12635. private _offsetsCache;
  12636. /**
  12637. * The high limits cache of the runtime animation
  12638. */
  12639. private _highLimitsCache;
  12640. /**
  12641. * Specifies if the runtime animation has been stopped
  12642. */
  12643. private _stopped;
  12644. /**
  12645. * The blending factor of the runtime animation
  12646. */
  12647. private _blendingFactor;
  12648. /**
  12649. * The BabylonJS scene
  12650. */
  12651. private _scene;
  12652. /**
  12653. * The current value of the runtime animation
  12654. */
  12655. private _currentValue;
  12656. /** @hidden */
  12657. _animationState: _IAnimationState;
  12658. /**
  12659. * The active target of the runtime animation
  12660. */
  12661. private _activeTargets;
  12662. private _currentActiveTarget;
  12663. private _directTarget;
  12664. /**
  12665. * The target path of the runtime animation
  12666. */
  12667. private _targetPath;
  12668. /**
  12669. * The weight of the runtime animation
  12670. */
  12671. private _weight;
  12672. /**
  12673. * The ratio offset of the runtime animation
  12674. */
  12675. private _ratioOffset;
  12676. /**
  12677. * The previous delay of the runtime animation
  12678. */
  12679. private _previousDelay;
  12680. /**
  12681. * The previous ratio of the runtime animation
  12682. */
  12683. private _previousRatio;
  12684. private _enableBlending;
  12685. private _keys;
  12686. private _minFrame;
  12687. private _maxFrame;
  12688. private _minValue;
  12689. private _maxValue;
  12690. private _targetIsArray;
  12691. /**
  12692. * Gets the current frame of the runtime animation
  12693. */
  12694. readonly currentFrame: number;
  12695. /**
  12696. * Gets the weight of the runtime animation
  12697. */
  12698. readonly weight: number;
  12699. /**
  12700. * Gets the current value of the runtime animation
  12701. */
  12702. readonly currentValue: any;
  12703. /**
  12704. * Gets the target path of the runtime animation
  12705. */
  12706. readonly targetPath: string;
  12707. /**
  12708. * Gets the actual target of the runtime animation
  12709. */
  12710. readonly target: any;
  12711. /** @hidden */
  12712. _onLoop: () => void;
  12713. /**
  12714. * Create a new RuntimeAnimation object
  12715. * @param target defines the target of the animation
  12716. * @param animation defines the source animation object
  12717. * @param scene defines the hosting scene
  12718. * @param host defines the initiating Animatable
  12719. */
  12720. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12721. private _preparePath;
  12722. /**
  12723. * Gets the animation from the runtime animation
  12724. */
  12725. readonly animation: Animation;
  12726. /**
  12727. * Resets the runtime animation to the beginning
  12728. * @param restoreOriginal defines whether to restore the target property to the original value
  12729. */
  12730. reset(restoreOriginal?: boolean): void;
  12731. /**
  12732. * Specifies if the runtime animation is stopped
  12733. * @returns Boolean specifying if the runtime animation is stopped
  12734. */
  12735. isStopped(): boolean;
  12736. /**
  12737. * Disposes of the runtime animation
  12738. */
  12739. dispose(): void;
  12740. /**
  12741. * Apply the interpolated value to the target
  12742. * @param currentValue defines the value computed by the animation
  12743. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12744. */
  12745. setValue(currentValue: any, weight: number): void;
  12746. private _getOriginalValues;
  12747. private _setValue;
  12748. /**
  12749. * Gets the loop pmode of the runtime animation
  12750. * @returns Loop Mode
  12751. */
  12752. private _getCorrectLoopMode;
  12753. /**
  12754. * Move the current animation to a given frame
  12755. * @param frame defines the frame to move to
  12756. */
  12757. goToFrame(frame: number): void;
  12758. /**
  12759. * @hidden Internal use only
  12760. */
  12761. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12762. /**
  12763. * Execute the current animation
  12764. * @param delay defines the delay to add to the current frame
  12765. * @param from defines the lower bound of the animation range
  12766. * @param to defines the upper bound of the animation range
  12767. * @param loop defines if the current animation must loop
  12768. * @param speedRatio defines the current speed ratio
  12769. * @param weight defines the weight of the animation (default is -1 so no weight)
  12770. * @param onLoop optional callback called when animation loops
  12771. * @returns a boolean indicating if the animation is running
  12772. */
  12773. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12774. }
  12775. }
  12776. declare module BABYLON {
  12777. /**
  12778. * Class used to store an actual running animation
  12779. */
  12780. export class Animatable {
  12781. /** defines the target object */
  12782. target: any;
  12783. /** defines the starting frame number (default is 0) */
  12784. fromFrame: number;
  12785. /** defines the ending frame number (default is 100) */
  12786. toFrame: number;
  12787. /** defines if the animation must loop (default is false) */
  12788. loopAnimation: boolean;
  12789. /** defines a callback to call when animation ends if it is not looping */
  12790. onAnimationEnd?: (() => void) | null | undefined;
  12791. /** defines a callback to call when animation loops */
  12792. onAnimationLoop?: (() => void) | null | undefined;
  12793. private _localDelayOffset;
  12794. private _pausedDelay;
  12795. private _runtimeAnimations;
  12796. private _paused;
  12797. private _scene;
  12798. private _speedRatio;
  12799. private _weight;
  12800. private _syncRoot;
  12801. /**
  12802. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12803. * This will only apply for non looping animation (default is true)
  12804. */
  12805. disposeOnEnd: boolean;
  12806. /**
  12807. * Gets a boolean indicating if the animation has started
  12808. */
  12809. animationStarted: boolean;
  12810. /**
  12811. * Observer raised when the animation ends
  12812. */
  12813. onAnimationEndObservable: Observable<Animatable>;
  12814. /**
  12815. * Observer raised when the animation loops
  12816. */
  12817. onAnimationLoopObservable: Observable<Animatable>;
  12818. /**
  12819. * Gets the root Animatable used to synchronize and normalize animations
  12820. */
  12821. readonly syncRoot: Nullable<Animatable>;
  12822. /**
  12823. * Gets the current frame of the first RuntimeAnimation
  12824. * Used to synchronize Animatables
  12825. */
  12826. readonly masterFrame: number;
  12827. /**
  12828. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12829. */
  12830. weight: number;
  12831. /**
  12832. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12833. */
  12834. speedRatio: number;
  12835. /**
  12836. * Creates a new Animatable
  12837. * @param scene defines the hosting scene
  12838. * @param target defines the target object
  12839. * @param fromFrame defines the starting frame number (default is 0)
  12840. * @param toFrame defines the ending frame number (default is 100)
  12841. * @param loopAnimation defines if the animation must loop (default is false)
  12842. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12843. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12844. * @param animations defines a group of animation to add to the new Animatable
  12845. * @param onAnimationLoop defines a callback to call when animation loops
  12846. */
  12847. constructor(scene: Scene,
  12848. /** defines the target object */
  12849. target: any,
  12850. /** defines the starting frame number (default is 0) */
  12851. fromFrame?: number,
  12852. /** defines the ending frame number (default is 100) */
  12853. toFrame?: number,
  12854. /** defines if the animation must loop (default is false) */
  12855. loopAnimation?: boolean, speedRatio?: number,
  12856. /** defines a callback to call when animation ends if it is not looping */
  12857. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12858. /** defines a callback to call when animation loops */
  12859. onAnimationLoop?: (() => void) | null | undefined);
  12860. /**
  12861. * Synchronize and normalize current Animatable with a source Animatable
  12862. * This is useful when using animation weights and when animations are not of the same length
  12863. * @param root defines the root Animatable to synchronize with
  12864. * @returns the current Animatable
  12865. */
  12866. syncWith(root: Animatable): Animatable;
  12867. /**
  12868. * Gets the list of runtime animations
  12869. * @returns an array of RuntimeAnimation
  12870. */
  12871. getAnimations(): RuntimeAnimation[];
  12872. /**
  12873. * Adds more animations to the current animatable
  12874. * @param target defines the target of the animations
  12875. * @param animations defines the new animations to add
  12876. */
  12877. appendAnimations(target: any, animations: Animation[]): void;
  12878. /**
  12879. * Gets the source animation for a specific property
  12880. * @param property defines the propertyu to look for
  12881. * @returns null or the source animation for the given property
  12882. */
  12883. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12884. /**
  12885. * Gets the runtime animation for a specific property
  12886. * @param property defines the propertyu to look for
  12887. * @returns null or the runtime animation for the given property
  12888. */
  12889. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12890. /**
  12891. * Resets the animatable to its original state
  12892. */
  12893. reset(): void;
  12894. /**
  12895. * Allows the animatable to blend with current running animations
  12896. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12897. * @param blendingSpeed defines the blending speed to use
  12898. */
  12899. enableBlending(blendingSpeed: number): void;
  12900. /**
  12901. * Disable animation blending
  12902. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12903. */
  12904. disableBlending(): void;
  12905. /**
  12906. * Jump directly to a given frame
  12907. * @param frame defines the frame to jump to
  12908. */
  12909. goToFrame(frame: number): void;
  12910. /**
  12911. * Pause the animation
  12912. */
  12913. pause(): void;
  12914. /**
  12915. * Restart the animation
  12916. */
  12917. restart(): void;
  12918. private _raiseOnAnimationEnd;
  12919. /**
  12920. * Stop and delete the current animation
  12921. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12922. * @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)
  12923. */
  12924. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12925. /**
  12926. * Wait asynchronously for the animation to end
  12927. * @returns a promise which will be fullfilled when the animation ends
  12928. */
  12929. waitAsync(): Promise<Animatable>;
  12930. /** @hidden */
  12931. _animate(delay: number): boolean;
  12932. }
  12933. interface Scene {
  12934. /** @hidden */
  12935. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12936. /** @hidden */
  12937. _processLateAnimationBindingsForMatrices(holder: {
  12938. totalWeight: number;
  12939. animations: RuntimeAnimation[];
  12940. originalValue: Matrix;
  12941. }): any;
  12942. /** @hidden */
  12943. _processLateAnimationBindingsForQuaternions(holder: {
  12944. totalWeight: number;
  12945. animations: RuntimeAnimation[];
  12946. originalValue: Quaternion;
  12947. }, refQuaternion: Quaternion): Quaternion;
  12948. /** @hidden */
  12949. _processLateAnimationBindings(): void;
  12950. /**
  12951. * Will start the animation sequence of a given target
  12952. * @param target defines the target
  12953. * @param from defines from which frame should animation start
  12954. * @param to defines until which frame should animation run.
  12955. * @param weight defines the weight to apply to the animation (1.0 by default)
  12956. * @param loop defines if the animation loops
  12957. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12958. * @param onAnimationEnd defines the function to be executed when the animation ends
  12959. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12960. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12961. * @param onAnimationLoop defines the callback to call when an animation loops
  12962. * @returns the animatable object created for this animation
  12963. */
  12964. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12965. /**
  12966. * Will start the animation sequence of a given target
  12967. * @param target defines the target
  12968. * @param from defines from which frame should animation start
  12969. * @param to defines until which frame should animation run.
  12970. * @param loop defines if the animation loops
  12971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12972. * @param onAnimationEnd defines the function to be executed when the animation ends
  12973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12974. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12975. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12976. * @param onAnimationLoop defines the callback to call when an animation loops
  12977. * @returns the animatable object created for this animation
  12978. */
  12979. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12980. /**
  12981. * Will start the animation sequence of a given target and its hierarchy
  12982. * @param target defines the target
  12983. * @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.
  12984. * @param from defines from which frame should animation start
  12985. * @param to defines until which frame should animation run.
  12986. * @param loop defines if the animation loops
  12987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12988. * @param onAnimationEnd defines the function to be executed when the animation ends
  12989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12991. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12992. * @param onAnimationLoop defines the callback to call when an animation loops
  12993. * @returns the list of created animatables
  12994. */
  12995. 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): Animatable[];
  12996. /**
  12997. * Begin a new animation on a given node
  12998. * @param target defines the target where the animation will take place
  12999. * @param animations defines the list of animations to start
  13000. * @param from defines the initial value
  13001. * @param to defines the final value
  13002. * @param loop defines if you want animation to loop (off by default)
  13003. * @param speedRatio defines the speed ratio to apply to all animations
  13004. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13005. * @param onAnimationLoop defines the callback to call when an animation loops
  13006. * @returns the list of created animatables
  13007. */
  13008. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13009. /**
  13010. * Begin a new animation on a given node and its hierarchy
  13011. * @param target defines the root node where the animation will take place
  13012. * @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.
  13013. * @param animations defines the list of animations to start
  13014. * @param from defines the initial value
  13015. * @param to defines the final value
  13016. * @param loop defines if you want animation to loop (off by default)
  13017. * @param speedRatio defines the speed ratio to apply to all animations
  13018. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13019. * @param onAnimationLoop defines the callback to call when an animation loops
  13020. * @returns the list of animatables created for all nodes
  13021. */
  13022. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13023. /**
  13024. * Gets the animatable associated with a specific target
  13025. * @param target defines the target of the animatable
  13026. * @returns the required animatable if found
  13027. */
  13028. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13029. /**
  13030. * Gets all animatables associated with a given target
  13031. * @param target defines the target to look animatables for
  13032. * @returns an array of Animatables
  13033. */
  13034. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13035. /**
  13036. * Stops and removes all animations that have been applied to the scene
  13037. */
  13038. stopAllAnimations(): void;
  13039. }
  13040. interface Bone {
  13041. /**
  13042. * Copy an animation range from another bone
  13043. * @param source defines the source bone
  13044. * @param rangeName defines the range name to copy
  13045. * @param frameOffset defines the frame offset
  13046. * @param rescaleAsRequired defines if rescaling must be applied if required
  13047. * @param skelDimensionsRatio defines the scaling ratio
  13048. * @returns true if operation was successful
  13049. */
  13050. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Class used to override all child animations of a given target
  13056. */
  13057. export class AnimationPropertiesOverride {
  13058. /**
  13059. * Gets or sets a value indicating if animation blending must be used
  13060. */
  13061. enableBlending: boolean;
  13062. /**
  13063. * Gets or sets the blending speed to use when enableBlending is true
  13064. */
  13065. blendingSpeed: number;
  13066. /**
  13067. * Gets or sets the default loop mode to use
  13068. */
  13069. loopMode: number;
  13070. }
  13071. }
  13072. declare module BABYLON {
  13073. /**
  13074. * Class used to handle skinning animations
  13075. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13076. */
  13077. export class Skeleton implements IAnimatable {
  13078. /** defines the skeleton name */
  13079. name: string;
  13080. /** defines the skeleton Id */
  13081. id: string;
  13082. /**
  13083. * Defines the list of child bones
  13084. */
  13085. bones: Bone[];
  13086. /**
  13087. * Defines an estimate of the dimension of the skeleton at rest
  13088. */
  13089. dimensionsAtRest: Vector3;
  13090. /**
  13091. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13092. */
  13093. needInitialSkinMatrix: boolean;
  13094. /**
  13095. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13096. */
  13097. overrideMesh: Nullable<AbstractMesh>;
  13098. /**
  13099. * Gets the list of animations attached to this skeleton
  13100. */
  13101. animations: Array<Animation>;
  13102. private _scene;
  13103. private _isDirty;
  13104. private _transformMatrices;
  13105. private _transformMatrixTexture;
  13106. private _meshesWithPoseMatrix;
  13107. private _animatables;
  13108. private _identity;
  13109. private _synchronizedWithMesh;
  13110. private _ranges;
  13111. private _lastAbsoluteTransformsUpdateId;
  13112. private _canUseTextureForBones;
  13113. private _uniqueId;
  13114. /** @hidden */
  13115. _numBonesWithLinkedTransformNode: number;
  13116. /** @hidden */
  13117. _hasWaitingData: Nullable<boolean>;
  13118. /**
  13119. * Specifies if the skeleton should be serialized
  13120. */
  13121. doNotSerialize: boolean;
  13122. private _useTextureToStoreBoneMatrices;
  13123. /**
  13124. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13125. * Please note that this option is not available if the hardware does not support it
  13126. */
  13127. useTextureToStoreBoneMatrices: boolean;
  13128. private _animationPropertiesOverride;
  13129. /**
  13130. * Gets or sets the animation properties override
  13131. */
  13132. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13133. /**
  13134. * List of inspectable custom properties (used by the Inspector)
  13135. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13136. */
  13137. inspectableCustomProperties: IInspectable[];
  13138. /**
  13139. * An observable triggered before computing the skeleton's matrices
  13140. */
  13141. onBeforeComputeObservable: Observable<Skeleton>;
  13142. /**
  13143. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13144. */
  13145. readonly isUsingTextureForMatrices: boolean;
  13146. /**
  13147. * Gets the unique ID of this skeleton
  13148. */
  13149. readonly uniqueId: number;
  13150. /**
  13151. * Creates a new skeleton
  13152. * @param name defines the skeleton name
  13153. * @param id defines the skeleton Id
  13154. * @param scene defines the hosting scene
  13155. */
  13156. constructor(
  13157. /** defines the skeleton name */
  13158. name: string,
  13159. /** defines the skeleton Id */
  13160. id: string, scene: Scene);
  13161. /**
  13162. * Gets the current object class name.
  13163. * @return the class name
  13164. */
  13165. getClassName(): string;
  13166. /**
  13167. * Returns an array containing the root bones
  13168. * @returns an array containing the root bones
  13169. */
  13170. getChildren(): Array<Bone>;
  13171. /**
  13172. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13173. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13174. * @returns a Float32Array containing matrices data
  13175. */
  13176. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13177. /**
  13178. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13179. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13180. * @returns a raw texture containing the data
  13181. */
  13182. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13183. /**
  13184. * Gets the current hosting scene
  13185. * @returns a scene object
  13186. */
  13187. getScene(): Scene;
  13188. /**
  13189. * Gets a string representing the current skeleton data
  13190. * @param fullDetails defines a boolean indicating if we want a verbose version
  13191. * @returns a string representing the current skeleton data
  13192. */
  13193. toString(fullDetails?: boolean): string;
  13194. /**
  13195. * Get bone's index searching by name
  13196. * @param name defines bone's name to search for
  13197. * @return the indice of the bone. Returns -1 if not found
  13198. */
  13199. getBoneIndexByName(name: string): number;
  13200. /**
  13201. * Creater a new animation range
  13202. * @param name defines the name of the range
  13203. * @param from defines the start key
  13204. * @param to defines the end key
  13205. */
  13206. createAnimationRange(name: string, from: number, to: number): void;
  13207. /**
  13208. * Delete a specific animation range
  13209. * @param name defines the name of the range
  13210. * @param deleteFrames defines if frames must be removed as well
  13211. */
  13212. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13213. /**
  13214. * Gets a specific animation range
  13215. * @param name defines the name of the range to look for
  13216. * @returns the requested animation range or null if not found
  13217. */
  13218. getAnimationRange(name: string): Nullable<AnimationRange>;
  13219. /**
  13220. * Gets the list of all animation ranges defined on this skeleton
  13221. * @returns an array
  13222. */
  13223. getAnimationRanges(): Nullable<AnimationRange>[];
  13224. /**
  13225. * Copy animation range from a source skeleton.
  13226. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13227. * @param source defines the source skeleton
  13228. * @param name defines the name of the range to copy
  13229. * @param rescaleAsRequired defines if rescaling must be applied if required
  13230. * @returns true if operation was successful
  13231. */
  13232. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13233. /**
  13234. * Forces the skeleton to go to rest pose
  13235. */
  13236. returnToRest(): void;
  13237. private _getHighestAnimationFrame;
  13238. /**
  13239. * Begin a specific animation range
  13240. * @param name defines the name of the range to start
  13241. * @param loop defines if looping must be turned on (false by default)
  13242. * @param speedRatio defines the speed ratio to apply (1 by default)
  13243. * @param onAnimationEnd defines a callback which will be called when animation will end
  13244. * @returns a new animatable
  13245. */
  13246. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13247. /** @hidden */
  13248. _markAsDirty(): void;
  13249. /** @hidden */
  13250. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13251. /** @hidden */
  13252. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13253. private _computeTransformMatrices;
  13254. /**
  13255. * Build all resources required to render a skeleton
  13256. */
  13257. prepare(): void;
  13258. /**
  13259. * Gets the list of animatables currently running for this skeleton
  13260. * @returns an array of animatables
  13261. */
  13262. getAnimatables(): IAnimatable[];
  13263. /**
  13264. * Clone the current skeleton
  13265. * @param name defines the name of the new skeleton
  13266. * @param id defines the id of the new skeleton
  13267. * @returns the new skeleton
  13268. */
  13269. clone(name: string, id: string): Skeleton;
  13270. /**
  13271. * Enable animation blending for this skeleton
  13272. * @param blendingSpeed defines the blending speed to apply
  13273. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13274. */
  13275. enableBlending(blendingSpeed?: number): void;
  13276. /**
  13277. * Releases all resources associated with the current skeleton
  13278. */
  13279. dispose(): void;
  13280. /**
  13281. * Serialize the skeleton in a JSON object
  13282. * @returns a JSON object
  13283. */
  13284. serialize(): any;
  13285. /**
  13286. * Creates a new skeleton from serialized data
  13287. * @param parsedSkeleton defines the serialized data
  13288. * @param scene defines the hosting scene
  13289. * @returns a new skeleton
  13290. */
  13291. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13292. /**
  13293. * Compute all node absolute transforms
  13294. * @param forceUpdate defines if computation must be done even if cache is up to date
  13295. */
  13296. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13297. /**
  13298. * Gets the root pose matrix
  13299. * @returns a matrix
  13300. */
  13301. getPoseMatrix(): Nullable<Matrix>;
  13302. /**
  13303. * Sorts bones per internal index
  13304. */
  13305. sortBones(): void;
  13306. private _sortBones;
  13307. }
  13308. }
  13309. declare module BABYLON {
  13310. /**
  13311. * Class used to store bone information
  13312. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13313. */
  13314. export class Bone extends Node {
  13315. /**
  13316. * defines the bone name
  13317. */
  13318. name: string;
  13319. private static _tmpVecs;
  13320. private static _tmpQuat;
  13321. private static _tmpMats;
  13322. /**
  13323. * Gets the list of child bones
  13324. */
  13325. children: Bone[];
  13326. /** Gets the animations associated with this bone */
  13327. animations: Animation[];
  13328. /**
  13329. * Gets or sets bone length
  13330. */
  13331. length: number;
  13332. /**
  13333. * @hidden Internal only
  13334. * Set this value to map this bone to a different index in the transform matrices
  13335. * Set this value to -1 to exclude the bone from the transform matrices
  13336. */
  13337. _index: Nullable<number>;
  13338. private _skeleton;
  13339. private _localMatrix;
  13340. private _restPose;
  13341. private _baseMatrix;
  13342. private _absoluteTransform;
  13343. private _invertedAbsoluteTransform;
  13344. private _parent;
  13345. private _scalingDeterminant;
  13346. private _worldTransform;
  13347. private _localScaling;
  13348. private _localRotation;
  13349. private _localPosition;
  13350. private _needToDecompose;
  13351. private _needToCompose;
  13352. /** @hidden */
  13353. _linkedTransformNode: Nullable<TransformNode>;
  13354. /** @hidden */
  13355. _waitingTransformNodeId: Nullable<string>;
  13356. /** @hidden */
  13357. /** @hidden */
  13358. _matrix: Matrix;
  13359. /**
  13360. * Create a new bone
  13361. * @param name defines the bone name
  13362. * @param skeleton defines the parent skeleton
  13363. * @param parentBone defines the parent (can be null if the bone is the root)
  13364. * @param localMatrix defines the local matrix
  13365. * @param restPose defines the rest pose matrix
  13366. * @param baseMatrix defines the base matrix
  13367. * @param index defines index of the bone in the hiearchy
  13368. */
  13369. constructor(
  13370. /**
  13371. * defines the bone name
  13372. */
  13373. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13374. /**
  13375. * Gets the current object class name.
  13376. * @return the class name
  13377. */
  13378. getClassName(): string;
  13379. /**
  13380. * Gets the parent skeleton
  13381. * @returns a skeleton
  13382. */
  13383. getSkeleton(): Skeleton;
  13384. /**
  13385. * Gets parent bone
  13386. * @returns a bone or null if the bone is the root of the bone hierarchy
  13387. */
  13388. getParent(): Nullable<Bone>;
  13389. /**
  13390. * Returns an array containing the root bones
  13391. * @returns an array containing the root bones
  13392. */
  13393. getChildren(): Array<Bone>;
  13394. /**
  13395. * Sets the parent bone
  13396. * @param parent defines the parent (can be null if the bone is the root)
  13397. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13398. */
  13399. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13400. /**
  13401. * Gets the local matrix
  13402. * @returns a matrix
  13403. */
  13404. getLocalMatrix(): Matrix;
  13405. /**
  13406. * Gets the base matrix (initial matrix which remains unchanged)
  13407. * @returns a matrix
  13408. */
  13409. getBaseMatrix(): Matrix;
  13410. /**
  13411. * Gets the rest pose matrix
  13412. * @returns a matrix
  13413. */
  13414. getRestPose(): Matrix;
  13415. /**
  13416. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13417. */
  13418. getWorldMatrix(): Matrix;
  13419. /**
  13420. * Sets the local matrix to rest pose matrix
  13421. */
  13422. returnToRest(): void;
  13423. /**
  13424. * Gets the inverse of the absolute transform matrix.
  13425. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13426. * @returns a matrix
  13427. */
  13428. getInvertedAbsoluteTransform(): Matrix;
  13429. /**
  13430. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13431. * @returns a matrix
  13432. */
  13433. getAbsoluteTransform(): Matrix;
  13434. /**
  13435. * Links with the given transform node.
  13436. * The local matrix of this bone is copied from the transform node every frame.
  13437. * @param transformNode defines the transform node to link to
  13438. */
  13439. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13440. /**
  13441. * Gets the node used to drive the bone's transformation
  13442. * @returns a transform node or null
  13443. */
  13444. getTransformNode(): Nullable<TransformNode>;
  13445. /** Gets or sets current position (in local space) */
  13446. position: Vector3;
  13447. /** Gets or sets current rotation (in local space) */
  13448. rotation: Vector3;
  13449. /** Gets or sets current rotation quaternion (in local space) */
  13450. rotationQuaternion: Quaternion;
  13451. /** Gets or sets current scaling (in local space) */
  13452. scaling: Vector3;
  13453. /**
  13454. * Gets the animation properties override
  13455. */
  13456. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13457. private _decompose;
  13458. private _compose;
  13459. /**
  13460. * Update the base and local matrices
  13461. * @param matrix defines the new base or local matrix
  13462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13463. * @param updateLocalMatrix defines if the local matrix should be updated
  13464. */
  13465. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13466. /** @hidden */
  13467. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13468. /**
  13469. * Flag the bone as dirty (Forcing it to update everything)
  13470. */
  13471. markAsDirty(): void;
  13472. /** @hidden */
  13473. _markAsDirtyAndCompose(): void;
  13474. private _markAsDirtyAndDecompose;
  13475. /**
  13476. * Translate the bone in local or world space
  13477. * @param vec The amount to translate the bone
  13478. * @param space The space that the translation is in
  13479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13480. */
  13481. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13482. /**
  13483. * Set the postion of the bone in local or world space
  13484. * @param position The position to set the bone
  13485. * @param space The space that the position is in
  13486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13487. */
  13488. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13489. /**
  13490. * Set the absolute position of the bone (world space)
  13491. * @param position The position to set the bone
  13492. * @param mesh The mesh that this bone is attached to
  13493. */
  13494. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13495. /**
  13496. * Scale the bone on the x, y and z axes (in local space)
  13497. * @param x The amount to scale the bone on the x axis
  13498. * @param y The amount to scale the bone on the y axis
  13499. * @param z The amount to scale the bone on the z axis
  13500. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13501. */
  13502. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13503. /**
  13504. * Set the bone scaling in local space
  13505. * @param scale defines the scaling vector
  13506. */
  13507. setScale(scale: Vector3): void;
  13508. /**
  13509. * Gets the current scaling in local space
  13510. * @returns the current scaling vector
  13511. */
  13512. getScale(): Vector3;
  13513. /**
  13514. * Gets the current scaling in local space and stores it in a target vector
  13515. * @param result defines the target vector
  13516. */
  13517. getScaleToRef(result: Vector3): void;
  13518. /**
  13519. * Set the yaw, pitch, and roll of the bone in local or world space
  13520. * @param yaw The rotation of the bone on the y axis
  13521. * @param pitch The rotation of the bone on the x axis
  13522. * @param roll The rotation of the bone on the z axis
  13523. * @param space The space that the axes of rotation are in
  13524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13525. */
  13526. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13527. /**
  13528. * Add a rotation to the bone on an axis in local or world space
  13529. * @param axis The axis to rotate the bone on
  13530. * @param amount The amount to rotate the bone
  13531. * @param space The space that the axis is in
  13532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13533. */
  13534. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13535. /**
  13536. * Set the rotation of the bone to a particular axis angle in local or world space
  13537. * @param axis The axis to rotate the bone on
  13538. * @param angle The angle that the bone should be rotated to
  13539. * @param space The space that the axis is in
  13540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13541. */
  13542. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13543. /**
  13544. * Set the euler rotation of the bone in local of world space
  13545. * @param rotation The euler rotation that the bone should be set to
  13546. * @param space The space that the rotation is in
  13547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13548. */
  13549. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13550. /**
  13551. * Set the quaternion rotation of the bone in local of world space
  13552. * @param quat The quaternion rotation that the bone should be set to
  13553. * @param space The space that the rotation is in
  13554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13555. */
  13556. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13557. /**
  13558. * Set the rotation matrix of the bone in local of world space
  13559. * @param rotMat The rotation matrix that the bone should be set to
  13560. * @param space The space that the rotation is in
  13561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13562. */
  13563. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13564. private _rotateWithMatrix;
  13565. private _getNegativeRotationToRef;
  13566. /**
  13567. * Get the position of the bone in local or world space
  13568. * @param space The space that the returned position is in
  13569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13570. * @returns The position of the bone
  13571. */
  13572. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13573. /**
  13574. * Copy the position of the bone to a vector3 in local or world space
  13575. * @param space The space that the returned position is in
  13576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13577. * @param result The vector3 to copy the position to
  13578. */
  13579. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13580. /**
  13581. * Get the absolute position of the bone (world space)
  13582. * @param mesh The mesh that this bone is attached to
  13583. * @returns The absolute position of the bone
  13584. */
  13585. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13586. /**
  13587. * Copy the absolute position of the bone (world space) to the result param
  13588. * @param mesh The mesh that this bone is attached to
  13589. * @param result The vector3 to copy the absolute position to
  13590. */
  13591. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13592. /**
  13593. * Compute the absolute transforms of this bone and its children
  13594. */
  13595. computeAbsoluteTransforms(): void;
  13596. /**
  13597. * Get the world direction from an axis that is in the local space of the bone
  13598. * @param localAxis The local direction that is used to compute the world direction
  13599. * @param mesh The mesh that this bone is attached to
  13600. * @returns The world direction
  13601. */
  13602. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13603. /**
  13604. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13605. * @param localAxis The local direction that is used to compute the world direction
  13606. * @param mesh The mesh that this bone is attached to
  13607. * @param result The vector3 that the world direction will be copied to
  13608. */
  13609. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13610. /**
  13611. * Get the euler rotation of the bone in local or world space
  13612. * @param space The space that the rotation should be in
  13613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13614. * @returns The euler rotation
  13615. */
  13616. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13617. /**
  13618. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13619. * @param space The space that the rotation should be in
  13620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13621. * @param result The vector3 that the rotation should be copied to
  13622. */
  13623. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13624. /**
  13625. * Get the quaternion rotation of the bone in either local or world space
  13626. * @param space The space that the rotation should be in
  13627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13628. * @returns The quaternion rotation
  13629. */
  13630. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13631. /**
  13632. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13633. * @param space The space that the rotation should be in
  13634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13635. * @param result The quaternion that the rotation should be copied to
  13636. */
  13637. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13638. /**
  13639. * Get the rotation matrix of the bone in local or world space
  13640. * @param space The space that the rotation should be in
  13641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13642. * @returns The rotation matrix
  13643. */
  13644. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13645. /**
  13646. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13647. * @param space The space that the rotation should be in
  13648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13649. * @param result The quaternion that the rotation should be copied to
  13650. */
  13651. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13652. /**
  13653. * Get the world position of a point that is in the local space of the bone
  13654. * @param position The local position
  13655. * @param mesh The mesh that this bone is attached to
  13656. * @returns The world position
  13657. */
  13658. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13659. /**
  13660. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13661. * @param position The local position
  13662. * @param mesh The mesh that this bone is attached to
  13663. * @param result The vector3 that the world position should be copied to
  13664. */
  13665. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13666. /**
  13667. * Get the local position of a point that is in world space
  13668. * @param position The world position
  13669. * @param mesh The mesh that this bone is attached to
  13670. * @returns The local position
  13671. */
  13672. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13673. /**
  13674. * Get the local position of a point that is in world space and copy it to the result param
  13675. * @param position The world position
  13676. * @param mesh The mesh that this bone is attached to
  13677. * @param result The vector3 that the local position should be copied to
  13678. */
  13679. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13680. }
  13681. }
  13682. declare module BABYLON {
  13683. /**
  13684. * 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.
  13685. * @see https://doc.babylonjs.com/how_to/transformnode
  13686. */
  13687. export class TransformNode extends Node {
  13688. /**
  13689. * Object will not rotate to face the camera
  13690. */
  13691. static BILLBOARDMODE_NONE: number;
  13692. /**
  13693. * Object will rotate to face the camera but only on the x axis
  13694. */
  13695. static BILLBOARDMODE_X: number;
  13696. /**
  13697. * Object will rotate to face the camera but only on the y axis
  13698. */
  13699. static BILLBOARDMODE_Y: number;
  13700. /**
  13701. * Object will rotate to face the camera but only on the z axis
  13702. */
  13703. static BILLBOARDMODE_Z: number;
  13704. /**
  13705. * Object will rotate to face the camera
  13706. */
  13707. static BILLBOARDMODE_ALL: number;
  13708. /**
  13709. * Object will rotate to face the camera's position instead of orientation
  13710. */
  13711. static BILLBOARDMODE_USE_POSITION: number;
  13712. private _forward;
  13713. private _forwardInverted;
  13714. private _up;
  13715. private _right;
  13716. private _rightInverted;
  13717. private _position;
  13718. private _rotation;
  13719. private _rotationQuaternion;
  13720. protected _scaling: Vector3;
  13721. protected _isDirty: boolean;
  13722. private _transformToBoneReferal;
  13723. private _isAbsoluteSynced;
  13724. private _billboardMode;
  13725. /**
  13726. * Gets or sets the billboard mode. Default is 0.
  13727. *
  13728. * | Value | Type | Description |
  13729. * | --- | --- | --- |
  13730. * | 0 | BILLBOARDMODE_NONE | |
  13731. * | 1 | BILLBOARDMODE_X | |
  13732. * | 2 | BILLBOARDMODE_Y | |
  13733. * | 4 | BILLBOARDMODE_Z | |
  13734. * | 7 | BILLBOARDMODE_ALL | |
  13735. *
  13736. */
  13737. billboardMode: number;
  13738. private _preserveParentRotationForBillboard;
  13739. /**
  13740. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13741. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13742. */
  13743. preserveParentRotationForBillboard: boolean;
  13744. /**
  13745. * 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
  13746. */
  13747. scalingDeterminant: number;
  13748. private _infiniteDistance;
  13749. /**
  13750. * Gets or sets the distance of the object to max, often used by skybox
  13751. */
  13752. infiniteDistance: boolean;
  13753. /**
  13754. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13755. * By default the system will update normals to compensate
  13756. */
  13757. ignoreNonUniformScaling: boolean;
  13758. /**
  13759. * 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
  13760. */
  13761. reIntegrateRotationIntoRotationQuaternion: boolean;
  13762. /** @hidden */
  13763. _poseMatrix: Nullable<Matrix>;
  13764. /** @hidden */
  13765. _localMatrix: Matrix;
  13766. private _usePivotMatrix;
  13767. private _absolutePosition;
  13768. private _absoluteScaling;
  13769. private _absoluteRotationQuaternion;
  13770. private _pivotMatrix;
  13771. private _pivotMatrixInverse;
  13772. protected _postMultiplyPivotMatrix: boolean;
  13773. protected _isWorldMatrixFrozen: boolean;
  13774. /** @hidden */
  13775. _indexInSceneTransformNodesArray: number;
  13776. /**
  13777. * An event triggered after the world matrix is updated
  13778. */
  13779. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13780. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13781. /**
  13782. * Gets a string identifying the name of the class
  13783. * @returns "TransformNode" string
  13784. */
  13785. getClassName(): string;
  13786. /**
  13787. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13788. */
  13789. position: Vector3;
  13790. /**
  13791. * 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)).
  13792. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13793. */
  13794. rotation: Vector3;
  13795. /**
  13796. * 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)).
  13797. */
  13798. scaling: Vector3;
  13799. /**
  13800. * 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).
  13801. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13802. */
  13803. rotationQuaternion: Nullable<Quaternion>;
  13804. /**
  13805. * The forward direction of that transform in world space.
  13806. */
  13807. readonly forward: Vector3;
  13808. /**
  13809. * The up direction of that transform in world space.
  13810. */
  13811. readonly up: Vector3;
  13812. /**
  13813. * The right direction of that transform in world space.
  13814. */
  13815. readonly right: Vector3;
  13816. /**
  13817. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13818. * @param matrix the matrix to copy the pose from
  13819. * @returns this TransformNode.
  13820. */
  13821. updatePoseMatrix(matrix: Matrix): TransformNode;
  13822. /**
  13823. * Returns the mesh Pose matrix.
  13824. * @returns the pose matrix
  13825. */
  13826. getPoseMatrix(): Matrix;
  13827. /** @hidden */
  13828. _isSynchronized(): boolean;
  13829. /** @hidden */
  13830. _initCache(): void;
  13831. /**
  13832. * Flag the transform node as dirty (Forcing it to update everything)
  13833. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13834. * @returns this transform node
  13835. */
  13836. markAsDirty(property: string): TransformNode;
  13837. /**
  13838. * Returns the current mesh absolute position.
  13839. * Returns a Vector3.
  13840. */
  13841. readonly absolutePosition: Vector3;
  13842. /**
  13843. * Returns the current mesh absolute scaling.
  13844. * Returns a Vector3.
  13845. */
  13846. readonly absoluteScaling: Vector3;
  13847. /**
  13848. * Returns the current mesh absolute rotation.
  13849. * Returns a Quaternion.
  13850. */
  13851. readonly absoluteRotationQuaternion: Quaternion;
  13852. /**
  13853. * Sets a new matrix to apply before all other transformation
  13854. * @param matrix defines the transform matrix
  13855. * @returns the current TransformNode
  13856. */
  13857. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13858. /**
  13859. * Sets a new pivot matrix to the current node
  13860. * @param matrix defines the new pivot matrix to use
  13861. * @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
  13862. * @returns the current TransformNode
  13863. */
  13864. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13865. /**
  13866. * Returns the mesh pivot matrix.
  13867. * Default : Identity.
  13868. * @returns the matrix
  13869. */
  13870. getPivotMatrix(): Matrix;
  13871. /**
  13872. * Instantiate (when possible) or clone that node with its hierarchy
  13873. * @param newParent defines the new parent to use for the instance (or clone)
  13874. * @returns an instance (or a clone) of the current node with its hiearchy
  13875. */
  13876. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13877. /**
  13878. * Prevents the World matrix to be computed any longer
  13879. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13880. * @returns the TransformNode.
  13881. */
  13882. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13883. /**
  13884. * Allows back the World matrix computation.
  13885. * @returns the TransformNode.
  13886. */
  13887. unfreezeWorldMatrix(): this;
  13888. /**
  13889. * True if the World matrix has been frozen.
  13890. */
  13891. readonly isWorldMatrixFrozen: boolean;
  13892. /**
  13893. * Retuns the mesh absolute position in the World.
  13894. * @returns a Vector3.
  13895. */
  13896. getAbsolutePosition(): Vector3;
  13897. /**
  13898. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13899. * @param absolutePosition the absolute position to set
  13900. * @returns the TransformNode.
  13901. */
  13902. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13903. /**
  13904. * Sets the mesh position in its local space.
  13905. * @param vector3 the position to set in localspace
  13906. * @returns the TransformNode.
  13907. */
  13908. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13909. /**
  13910. * Returns the mesh position in the local space from the current World matrix values.
  13911. * @returns a new Vector3.
  13912. */
  13913. getPositionExpressedInLocalSpace(): Vector3;
  13914. /**
  13915. * Translates the mesh along the passed Vector3 in its local space.
  13916. * @param vector3 the distance to translate in localspace
  13917. * @returns the TransformNode.
  13918. */
  13919. locallyTranslate(vector3: Vector3): TransformNode;
  13920. private static _lookAtVectorCache;
  13921. /**
  13922. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13923. * @param targetPoint the position (must be in same space as current mesh) to look at
  13924. * @param yawCor optional yaw (y-axis) correction in radians
  13925. * @param pitchCor optional pitch (x-axis) correction in radians
  13926. * @param rollCor optional roll (z-axis) correction in radians
  13927. * @param space the choosen space of the target
  13928. * @returns the TransformNode.
  13929. */
  13930. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13931. /**
  13932. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13933. * This Vector3 is expressed in the World space.
  13934. * @param localAxis axis to rotate
  13935. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13936. */
  13937. getDirection(localAxis: Vector3): Vector3;
  13938. /**
  13939. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13940. * localAxis is expressed in the mesh local space.
  13941. * result is computed in the Wordl space from the mesh World matrix.
  13942. * @param localAxis axis to rotate
  13943. * @param result the resulting transformnode
  13944. * @returns this TransformNode.
  13945. */
  13946. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13947. /**
  13948. * Sets this transform node rotation to the given local axis.
  13949. * @param localAxis the axis in local space
  13950. * @param yawCor optional yaw (y-axis) correction in radians
  13951. * @param pitchCor optional pitch (x-axis) correction in radians
  13952. * @param rollCor optional roll (z-axis) correction in radians
  13953. * @returns this TransformNode
  13954. */
  13955. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13956. /**
  13957. * Sets a new pivot point to the current node
  13958. * @param point defines the new pivot point to use
  13959. * @param space defines if the point is in world or local space (local by default)
  13960. * @returns the current TransformNode
  13961. */
  13962. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13963. /**
  13964. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13965. * @returns the pivot point
  13966. */
  13967. getPivotPoint(): Vector3;
  13968. /**
  13969. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13970. * @param result the vector3 to store the result
  13971. * @returns this TransformNode.
  13972. */
  13973. getPivotPointToRef(result: Vector3): TransformNode;
  13974. /**
  13975. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13976. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13977. */
  13978. getAbsolutePivotPoint(): Vector3;
  13979. /**
  13980. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13981. * @param result vector3 to store the result
  13982. * @returns this TransformNode.
  13983. */
  13984. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13985. /**
  13986. * Defines the passed node as the parent of the current node.
  13987. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13988. * @see https://doc.babylonjs.com/how_to/parenting
  13989. * @param node the node ot set as the parent
  13990. * @returns this TransformNode.
  13991. */
  13992. setParent(node: Nullable<Node>): TransformNode;
  13993. private _nonUniformScaling;
  13994. /**
  13995. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13996. */
  13997. readonly nonUniformScaling: boolean;
  13998. /** @hidden */
  13999. _updateNonUniformScalingState(value: boolean): boolean;
  14000. /**
  14001. * Attach the current TransformNode to another TransformNode associated with a bone
  14002. * @param bone Bone affecting the TransformNode
  14003. * @param affectedTransformNode TransformNode associated with the bone
  14004. * @returns this object
  14005. */
  14006. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14007. /**
  14008. * Detach the transform node if its associated with a bone
  14009. * @returns this object
  14010. */
  14011. detachFromBone(): TransformNode;
  14012. private static _rotationAxisCache;
  14013. /**
  14014. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14015. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14016. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14017. * The passed axis is also normalized.
  14018. * @param axis the axis to rotate around
  14019. * @param amount the amount to rotate in radians
  14020. * @param space Space to rotate in (Default: local)
  14021. * @returns the TransformNode.
  14022. */
  14023. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14024. /**
  14025. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14026. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14027. * The passed axis is also normalized. .
  14028. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14029. * @param point the point to rotate around
  14030. * @param axis the axis to rotate around
  14031. * @param amount the amount to rotate in radians
  14032. * @returns the TransformNode
  14033. */
  14034. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14035. /**
  14036. * Translates the mesh along the axis vector for the passed distance in the given space.
  14037. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14038. * @param axis the axis to translate in
  14039. * @param distance the distance to translate
  14040. * @param space Space to rotate in (Default: local)
  14041. * @returns the TransformNode.
  14042. */
  14043. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14044. /**
  14045. * Adds a rotation step to the mesh current rotation.
  14046. * x, y, z are Euler angles expressed in radians.
  14047. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14048. * This means this rotation is made in the mesh local space only.
  14049. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14050. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14051. * ```javascript
  14052. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14053. * ```
  14054. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14055. * 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.
  14056. * @param x Rotation to add
  14057. * @param y Rotation to add
  14058. * @param z Rotation to add
  14059. * @returns the TransformNode.
  14060. */
  14061. addRotation(x: number, y: number, z: number): TransformNode;
  14062. /**
  14063. * @hidden
  14064. */
  14065. protected _getEffectiveParent(): Nullable<Node>;
  14066. /**
  14067. * Computes the world matrix of the node
  14068. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14069. * @returns the world matrix
  14070. */
  14071. computeWorldMatrix(force?: boolean): Matrix;
  14072. protected _afterComputeWorldMatrix(): void;
  14073. /**
  14074. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14075. * @param func callback function to add
  14076. *
  14077. * @returns the TransformNode.
  14078. */
  14079. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14080. /**
  14081. * Removes a registered callback function.
  14082. * @param func callback function to remove
  14083. * @returns the TransformNode.
  14084. */
  14085. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14086. /**
  14087. * Gets the position of the current mesh in camera space
  14088. * @param camera defines the camera to use
  14089. * @returns a position
  14090. */
  14091. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14092. /**
  14093. * Returns the distance from the mesh to the active camera
  14094. * @param camera defines the camera to use
  14095. * @returns the distance
  14096. */
  14097. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14098. /**
  14099. * Clone the current transform node
  14100. * @param name Name of the new clone
  14101. * @param newParent New parent for the clone
  14102. * @param doNotCloneChildren Do not clone children hierarchy
  14103. * @returns the new transform node
  14104. */
  14105. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14106. /**
  14107. * Serializes the objects information.
  14108. * @param currentSerializationObject defines the object to serialize in
  14109. * @returns the serialized object
  14110. */
  14111. serialize(currentSerializationObject?: any): any;
  14112. /**
  14113. * Returns a new TransformNode object parsed from the source provided.
  14114. * @param parsedTransformNode is the source.
  14115. * @param scene the scne the object belongs to
  14116. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14117. * @returns a new TransformNode object parsed from the source provided.
  14118. */
  14119. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14120. /**
  14121. * Get all child-transformNodes of this node
  14122. * @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
  14123. * @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
  14124. * @returns an array of TransformNode
  14125. */
  14126. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14127. /**
  14128. * Releases resources associated with this transform node.
  14129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14131. */
  14132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14133. /**
  14134. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14135. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14136. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14137. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14138. * @returns the current mesh
  14139. */
  14140. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14141. private _syncAbsoluteScalingAndRotation;
  14142. }
  14143. }
  14144. declare module BABYLON {
  14145. /**
  14146. * Defines the types of pose enabled controllers that are supported
  14147. */
  14148. export enum PoseEnabledControllerType {
  14149. /**
  14150. * HTC Vive
  14151. */
  14152. VIVE = 0,
  14153. /**
  14154. * Oculus Rift
  14155. */
  14156. OCULUS = 1,
  14157. /**
  14158. * Windows mixed reality
  14159. */
  14160. WINDOWS = 2,
  14161. /**
  14162. * Samsung gear VR
  14163. */
  14164. GEAR_VR = 3,
  14165. /**
  14166. * Google Daydream
  14167. */
  14168. DAYDREAM = 4,
  14169. /**
  14170. * Generic
  14171. */
  14172. GENERIC = 5
  14173. }
  14174. /**
  14175. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14176. */
  14177. export interface MutableGamepadButton {
  14178. /**
  14179. * Value of the button/trigger
  14180. */
  14181. value: number;
  14182. /**
  14183. * If the button/trigger is currently touched
  14184. */
  14185. touched: boolean;
  14186. /**
  14187. * If the button/trigger is currently pressed
  14188. */
  14189. pressed: boolean;
  14190. }
  14191. /**
  14192. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14193. * @hidden
  14194. */
  14195. export interface ExtendedGamepadButton extends GamepadButton {
  14196. /**
  14197. * If the button/trigger is currently pressed
  14198. */
  14199. readonly pressed: boolean;
  14200. /**
  14201. * If the button/trigger is currently touched
  14202. */
  14203. readonly touched: boolean;
  14204. /**
  14205. * Value of the button/trigger
  14206. */
  14207. readonly value: number;
  14208. }
  14209. /** @hidden */
  14210. export interface _GamePadFactory {
  14211. /**
  14212. * Returns wether or not the current gamepad can be created for this type of controller.
  14213. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14214. * @returns true if it can be created, otherwise false
  14215. */
  14216. canCreate(gamepadInfo: any): boolean;
  14217. /**
  14218. * Creates a new instance of the Gamepad.
  14219. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14220. * @returns the new gamepad instance
  14221. */
  14222. create(gamepadInfo: any): Gamepad;
  14223. }
  14224. /**
  14225. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14226. */
  14227. export class PoseEnabledControllerHelper {
  14228. /** @hidden */
  14229. static _ControllerFactories: _GamePadFactory[];
  14230. /** @hidden */
  14231. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14232. /**
  14233. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14234. * @param vrGamepad the gamepad to initialized
  14235. * @returns a vr controller of the type the gamepad identified as
  14236. */
  14237. static InitiateController(vrGamepad: any): Gamepad;
  14238. }
  14239. /**
  14240. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14241. */
  14242. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14243. /**
  14244. * If the controller is used in a webXR session
  14245. */
  14246. isXR: boolean;
  14247. private _deviceRoomPosition;
  14248. private _deviceRoomRotationQuaternion;
  14249. /**
  14250. * The device position in babylon space
  14251. */
  14252. devicePosition: Vector3;
  14253. /**
  14254. * The device rotation in babylon space
  14255. */
  14256. deviceRotationQuaternion: Quaternion;
  14257. /**
  14258. * The scale factor of the device in babylon space
  14259. */
  14260. deviceScaleFactor: number;
  14261. /**
  14262. * (Likely devicePosition should be used instead) The device position in its room space
  14263. */
  14264. position: Vector3;
  14265. /**
  14266. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14267. */
  14268. rotationQuaternion: Quaternion;
  14269. /**
  14270. * The type of controller (Eg. Windows mixed reality)
  14271. */
  14272. controllerType: PoseEnabledControllerType;
  14273. protected _calculatedPosition: Vector3;
  14274. private _calculatedRotation;
  14275. /**
  14276. * The raw pose from the device
  14277. */
  14278. rawPose: DevicePose;
  14279. private _trackPosition;
  14280. private _maxRotationDistFromHeadset;
  14281. private _draggedRoomRotation;
  14282. /**
  14283. * @hidden
  14284. */
  14285. _disableTrackPosition(fixedPosition: Vector3): void;
  14286. /**
  14287. * Internal, the mesh attached to the controller
  14288. * @hidden
  14289. */
  14290. _mesh: Nullable<AbstractMesh>;
  14291. private _poseControlledCamera;
  14292. private _leftHandSystemQuaternion;
  14293. /**
  14294. * Internal, matrix used to convert room space to babylon space
  14295. * @hidden
  14296. */
  14297. _deviceToWorld: Matrix;
  14298. /**
  14299. * Node to be used when casting a ray from the controller
  14300. * @hidden
  14301. */
  14302. _pointingPoseNode: Nullable<TransformNode>;
  14303. /**
  14304. * Name of the child mesh that can be used to cast a ray from the controller
  14305. */
  14306. static readonly POINTING_POSE: string;
  14307. /**
  14308. * Creates a new PoseEnabledController from a gamepad
  14309. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14310. */
  14311. constructor(browserGamepad: any);
  14312. private _workingMatrix;
  14313. /**
  14314. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14315. */
  14316. update(): void;
  14317. /**
  14318. * Updates only the pose device and mesh without doing any button event checking
  14319. */
  14320. protected _updatePoseAndMesh(): void;
  14321. /**
  14322. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14323. * @param poseData raw pose fromthe device
  14324. */
  14325. updateFromDevice(poseData: DevicePose): void;
  14326. /**
  14327. * @hidden
  14328. */
  14329. _meshAttachedObservable: Observable<AbstractMesh>;
  14330. /**
  14331. * Attaches a mesh to the controller
  14332. * @param mesh the mesh to be attached
  14333. */
  14334. attachToMesh(mesh: AbstractMesh): void;
  14335. /**
  14336. * Attaches the controllers mesh to a camera
  14337. * @param camera the camera the mesh should be attached to
  14338. */
  14339. attachToPoseControlledCamera(camera: TargetCamera): void;
  14340. /**
  14341. * Disposes of the controller
  14342. */
  14343. dispose(): void;
  14344. /**
  14345. * The mesh that is attached to the controller
  14346. */
  14347. readonly mesh: Nullable<AbstractMesh>;
  14348. /**
  14349. * Gets the ray of the controller in the direction the controller is pointing
  14350. * @param length the length the resulting ray should be
  14351. * @returns a ray in the direction the controller is pointing
  14352. */
  14353. getForwardRay(length?: number): Ray;
  14354. }
  14355. }
  14356. declare module BABYLON {
  14357. /**
  14358. * Defines the WebVRController object that represents controllers tracked in 3D space
  14359. */
  14360. export abstract class WebVRController extends PoseEnabledController {
  14361. /**
  14362. * Internal, the default controller model for the controller
  14363. */
  14364. protected _defaultModel: AbstractMesh;
  14365. /**
  14366. * Fired when the trigger state has changed
  14367. */
  14368. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14369. /**
  14370. * Fired when the main button state has changed
  14371. */
  14372. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14373. /**
  14374. * Fired when the secondary button state has changed
  14375. */
  14376. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14377. /**
  14378. * Fired when the pad state has changed
  14379. */
  14380. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14381. /**
  14382. * Fired when controllers stick values have changed
  14383. */
  14384. onPadValuesChangedObservable: Observable<StickValues>;
  14385. /**
  14386. * Array of button availible on the controller
  14387. */
  14388. protected _buttons: Array<MutableGamepadButton>;
  14389. private _onButtonStateChange;
  14390. /**
  14391. * Fired when a controller button's state has changed
  14392. * @param callback the callback containing the button that was modified
  14393. */
  14394. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14395. /**
  14396. * X and Y axis corresponding to the controllers joystick
  14397. */
  14398. pad: StickValues;
  14399. /**
  14400. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14401. */
  14402. hand: string;
  14403. /**
  14404. * The default controller model for the controller
  14405. */
  14406. readonly defaultModel: AbstractMesh;
  14407. /**
  14408. * Creates a new WebVRController from a gamepad
  14409. * @param vrGamepad the gamepad that the WebVRController should be created from
  14410. */
  14411. constructor(vrGamepad: any);
  14412. /**
  14413. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14414. */
  14415. update(): void;
  14416. /**
  14417. * Function to be called when a button is modified
  14418. */
  14419. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14420. /**
  14421. * Loads a mesh and attaches it to the controller
  14422. * @param scene the scene the mesh should be added to
  14423. * @param meshLoaded callback for when the mesh has been loaded
  14424. */
  14425. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14426. private _setButtonValue;
  14427. private _changes;
  14428. private _checkChanges;
  14429. /**
  14430. * Disposes of th webVRCOntroller
  14431. */
  14432. dispose(): void;
  14433. }
  14434. }
  14435. declare module BABYLON {
  14436. /**
  14437. * The HemisphericLight simulates the ambient environment light,
  14438. * so the passed direction is the light reflection direction, not the incoming direction.
  14439. */
  14440. export class HemisphericLight extends Light {
  14441. /**
  14442. * The groundColor is the light in the opposite direction to the one specified during creation.
  14443. * 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.
  14444. */
  14445. groundColor: Color3;
  14446. /**
  14447. * The light reflection direction, not the incoming direction.
  14448. */
  14449. direction: Vector3;
  14450. /**
  14451. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14452. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14453. * The HemisphericLight can't cast shadows.
  14454. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14455. * @param name The friendly name of the light
  14456. * @param direction The direction of the light reflection
  14457. * @param scene The scene the light belongs to
  14458. */
  14459. constructor(name: string, direction: Vector3, scene: Scene);
  14460. protected _buildUniformLayout(): void;
  14461. /**
  14462. * Returns the string "HemisphericLight".
  14463. * @return The class name
  14464. */
  14465. getClassName(): string;
  14466. /**
  14467. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14468. * Returns the updated direction.
  14469. * @param target The target the direction should point to
  14470. * @return The computed direction
  14471. */
  14472. setDirectionToTarget(target: Vector3): Vector3;
  14473. /**
  14474. * Returns the shadow generator associated to the light.
  14475. * @returns Always null for hemispheric lights because it does not support shadows.
  14476. */
  14477. getShadowGenerator(): Nullable<IShadowGenerator>;
  14478. /**
  14479. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14480. * @param effect The effect to update
  14481. * @param lightIndex The index of the light in the effect to update
  14482. * @returns The hemispheric light
  14483. */
  14484. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14485. /**
  14486. * Computes the world matrix of the node
  14487. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14488. * @param useWasUpdatedFlag defines a reserved property
  14489. * @returns the world matrix
  14490. */
  14491. computeWorldMatrix(): Matrix;
  14492. /**
  14493. * Returns the integer 3.
  14494. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14495. */
  14496. getTypeID(): number;
  14497. /**
  14498. * Prepares the list of defines specific to the light type.
  14499. * @param defines the list of defines
  14500. * @param lightIndex defines the index of the light for the effect
  14501. */
  14502. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14503. }
  14504. }
  14505. declare module BABYLON {
  14506. /** @hidden */
  14507. export var vrMultiviewToSingleviewPixelShader: {
  14508. name: string;
  14509. shader: string;
  14510. };
  14511. }
  14512. declare module BABYLON {
  14513. /**
  14514. * Renders to multiple views with a single draw call
  14515. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14516. */
  14517. export class MultiviewRenderTarget extends RenderTargetTexture {
  14518. /**
  14519. * Creates a multiview render target
  14520. * @param scene scene used with the render target
  14521. * @param size the size of the render target (used for each view)
  14522. */
  14523. constructor(scene: Scene, size?: number | {
  14524. width: number;
  14525. height: number;
  14526. } | {
  14527. ratio: number;
  14528. });
  14529. /**
  14530. * @hidden
  14531. * @param faceIndex the face index, if its a cube texture
  14532. */
  14533. _bindFrameBuffer(faceIndex?: number): void;
  14534. /**
  14535. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14536. * @returns the view count
  14537. */
  14538. getViewCount(): number;
  14539. }
  14540. }
  14541. declare module BABYLON {
  14542. /**
  14543. * Reprasents a camera frustum
  14544. */
  14545. export class Frustum {
  14546. /**
  14547. * Gets the planes representing the frustum
  14548. * @param transform matrix to be applied to the returned planes
  14549. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14550. */
  14551. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14552. /**
  14553. * Gets the near frustum plane transformed by the transform matrix
  14554. * @param transform transformation matrix to be applied to the resulting frustum plane
  14555. * @param frustumPlane the resuling frustum plane
  14556. */
  14557. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14558. /**
  14559. * Gets the far frustum plane transformed by the transform matrix
  14560. * @param transform transformation matrix to be applied to the resulting frustum plane
  14561. * @param frustumPlane the resuling frustum plane
  14562. */
  14563. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14564. /**
  14565. * Gets the left frustum plane transformed by the transform matrix
  14566. * @param transform transformation matrix to be applied to the resulting frustum plane
  14567. * @param frustumPlane the resuling frustum plane
  14568. */
  14569. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14570. /**
  14571. * Gets the right frustum plane transformed by the transform matrix
  14572. * @param transform transformation matrix to be applied to the resulting frustum plane
  14573. * @param frustumPlane the resuling frustum plane
  14574. */
  14575. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14576. /**
  14577. * Gets the top frustum plane transformed by the transform matrix
  14578. * @param transform transformation matrix to be applied to the resulting frustum plane
  14579. * @param frustumPlane the resuling frustum plane
  14580. */
  14581. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14582. /**
  14583. * Gets the bottom frustum plane transformed by the transform matrix
  14584. * @param transform transformation matrix to be applied to the resulting frustum plane
  14585. * @param frustumPlane the resuling frustum plane
  14586. */
  14587. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14588. /**
  14589. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14590. * @param transform transformation matrix to be applied to the resulting frustum planes
  14591. * @param frustumPlanes the resuling frustum planes
  14592. */
  14593. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14594. }
  14595. }
  14596. declare module BABYLON {
  14597. interface Engine {
  14598. /**
  14599. * Creates a new multiview render target
  14600. * @param width defines the width of the texture
  14601. * @param height defines the height of the texture
  14602. * @returns the created multiview texture
  14603. */
  14604. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14605. /**
  14606. * Binds a multiview framebuffer to be drawn to
  14607. * @param multiviewTexture texture to bind
  14608. */
  14609. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14610. }
  14611. interface Camera {
  14612. /**
  14613. * @hidden
  14614. * 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)
  14615. */
  14616. _useMultiviewToSingleView: boolean;
  14617. /**
  14618. * @hidden
  14619. * 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)
  14620. */
  14621. _multiviewTexture: Nullable<RenderTargetTexture>;
  14622. /**
  14623. * @hidden
  14624. * ensures the multiview texture of the camera exists and has the specified width/height
  14625. * @param width height to set on the multiview texture
  14626. * @param height width to set on the multiview texture
  14627. */
  14628. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14629. }
  14630. interface Scene {
  14631. /** @hidden */
  14632. _transformMatrixR: Matrix;
  14633. /** @hidden */
  14634. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14635. /** @hidden */
  14636. _createMultiviewUbo(): void;
  14637. /** @hidden */
  14638. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14639. /** @hidden */
  14640. _renderMultiviewToSingleView(camera: Camera): void;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. /**
  14645. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14646. * This will not be used for webXR as it supports displaying texture arrays directly
  14647. */
  14648. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14649. /**
  14650. * Initializes a VRMultiviewToSingleview
  14651. * @param name name of the post process
  14652. * @param camera camera to be applied to
  14653. * @param scaleFactor scaling factor to the size of the output texture
  14654. */
  14655. constructor(name: string, camera: Camera, scaleFactor: number);
  14656. }
  14657. }
  14658. declare module BABYLON {
  14659. interface Engine {
  14660. /** @hidden */
  14661. _vrDisplay: any;
  14662. /** @hidden */
  14663. _vrSupported: boolean;
  14664. /** @hidden */
  14665. _oldSize: Size;
  14666. /** @hidden */
  14667. _oldHardwareScaleFactor: number;
  14668. /** @hidden */
  14669. _vrExclusivePointerMode: boolean;
  14670. /** @hidden */
  14671. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14672. /** @hidden */
  14673. _onVRDisplayPointerRestricted: () => void;
  14674. /** @hidden */
  14675. _onVRDisplayPointerUnrestricted: () => void;
  14676. /** @hidden */
  14677. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14678. /** @hidden */
  14679. _onVrDisplayDisconnect: Nullable<() => void>;
  14680. /** @hidden */
  14681. _onVrDisplayPresentChange: Nullable<() => void>;
  14682. /**
  14683. * Observable signaled when VR display mode changes
  14684. */
  14685. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14686. /**
  14687. * Observable signaled when VR request present is complete
  14688. */
  14689. onVRRequestPresentComplete: Observable<boolean>;
  14690. /**
  14691. * Observable signaled when VR request present starts
  14692. */
  14693. onVRRequestPresentStart: Observable<Engine>;
  14694. /**
  14695. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14696. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14697. */
  14698. isInVRExclusivePointerMode: boolean;
  14699. /**
  14700. * Gets a boolean indicating if a webVR device was detected
  14701. * @returns true if a webVR device was detected
  14702. */
  14703. isVRDevicePresent(): boolean;
  14704. /**
  14705. * Gets the current webVR device
  14706. * @returns the current webVR device (or null)
  14707. */
  14708. getVRDevice(): any;
  14709. /**
  14710. * Initializes a webVR display and starts listening to display change events
  14711. * The onVRDisplayChangedObservable will be notified upon these changes
  14712. * @returns A promise containing a VRDisplay and if vr is supported
  14713. */
  14714. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14715. /** @hidden */
  14716. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14717. /**
  14718. * Call this function to switch to webVR mode
  14719. * Will do nothing if webVR is not supported or if there is no webVR device
  14720. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14721. */
  14722. enableVR(): void;
  14723. /** @hidden */
  14724. _onVRFullScreenTriggered(): void;
  14725. }
  14726. }
  14727. declare module BABYLON {
  14728. /**
  14729. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14730. * IMPORTANT!! The data is right-hand data.
  14731. * @export
  14732. * @interface DevicePose
  14733. */
  14734. export interface DevicePose {
  14735. /**
  14736. * The position of the device, values in array are [x,y,z].
  14737. */
  14738. readonly position: Nullable<Float32Array>;
  14739. /**
  14740. * The linearVelocity of the device, values in array are [x,y,z].
  14741. */
  14742. readonly linearVelocity: Nullable<Float32Array>;
  14743. /**
  14744. * The linearAcceleration of the device, values in array are [x,y,z].
  14745. */
  14746. readonly linearAcceleration: Nullable<Float32Array>;
  14747. /**
  14748. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14749. */
  14750. readonly orientation: Nullable<Float32Array>;
  14751. /**
  14752. * The angularVelocity of the device, values in array are [x,y,z].
  14753. */
  14754. readonly angularVelocity: Nullable<Float32Array>;
  14755. /**
  14756. * The angularAcceleration of the device, values in array are [x,y,z].
  14757. */
  14758. readonly angularAcceleration: Nullable<Float32Array>;
  14759. }
  14760. /**
  14761. * Interface representing a pose controlled object in Babylon.
  14762. * A pose controlled object has both regular pose values as well as pose values
  14763. * from an external device such as a VR head mounted display
  14764. */
  14765. export interface PoseControlled {
  14766. /**
  14767. * The position of the object in babylon space.
  14768. */
  14769. position: Vector3;
  14770. /**
  14771. * The rotation quaternion of the object in babylon space.
  14772. */
  14773. rotationQuaternion: Quaternion;
  14774. /**
  14775. * The position of the device in babylon space.
  14776. */
  14777. devicePosition?: Vector3;
  14778. /**
  14779. * The rotation quaternion of the device in babylon space.
  14780. */
  14781. deviceRotationQuaternion: Quaternion;
  14782. /**
  14783. * The raw pose coming from the device.
  14784. */
  14785. rawPose: Nullable<DevicePose>;
  14786. /**
  14787. * The scale of the device to be used when translating from device space to babylon space.
  14788. */
  14789. deviceScaleFactor: number;
  14790. /**
  14791. * Updates the poseControlled values based on the input device pose.
  14792. * @param poseData the pose data to update the object with
  14793. */
  14794. updateFromDevice(poseData: DevicePose): void;
  14795. }
  14796. /**
  14797. * Set of options to customize the webVRCamera
  14798. */
  14799. export interface WebVROptions {
  14800. /**
  14801. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14802. */
  14803. trackPosition?: boolean;
  14804. /**
  14805. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14806. */
  14807. positionScale?: number;
  14808. /**
  14809. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14810. */
  14811. displayName?: string;
  14812. /**
  14813. * Should the native controller meshes be initialized. (default: true)
  14814. */
  14815. controllerMeshes?: boolean;
  14816. /**
  14817. * Creating a default HemiLight only on controllers. (default: true)
  14818. */
  14819. defaultLightingOnControllers?: boolean;
  14820. /**
  14821. * If you don't want to use the default VR button of the helper. (default: false)
  14822. */
  14823. useCustomVRButton?: boolean;
  14824. /**
  14825. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14826. */
  14827. customVRButton?: HTMLButtonElement;
  14828. /**
  14829. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14830. */
  14831. rayLength?: number;
  14832. /**
  14833. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14834. */
  14835. defaultHeight?: number;
  14836. /**
  14837. * If multiview should be used if availible (default: false)
  14838. */
  14839. useMultiview?: boolean;
  14840. }
  14841. /**
  14842. * This represents a WebVR camera.
  14843. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14844. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14845. */
  14846. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14847. private webVROptions;
  14848. /**
  14849. * @hidden
  14850. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14851. */
  14852. _vrDevice: any;
  14853. /**
  14854. * The rawPose of the vrDevice.
  14855. */
  14856. rawPose: Nullable<DevicePose>;
  14857. private _onVREnabled;
  14858. private _specsVersion;
  14859. private _attached;
  14860. private _frameData;
  14861. protected _descendants: Array<Node>;
  14862. private _deviceRoomPosition;
  14863. /** @hidden */
  14864. _deviceRoomRotationQuaternion: Quaternion;
  14865. private _standingMatrix;
  14866. /**
  14867. * Represents device position in babylon space.
  14868. */
  14869. devicePosition: Vector3;
  14870. /**
  14871. * Represents device rotation in babylon space.
  14872. */
  14873. deviceRotationQuaternion: Quaternion;
  14874. /**
  14875. * The scale of the device to be used when translating from device space to babylon space.
  14876. */
  14877. deviceScaleFactor: number;
  14878. private _deviceToWorld;
  14879. private _worldToDevice;
  14880. /**
  14881. * References to the webVR controllers for the vrDevice.
  14882. */
  14883. controllers: Array<WebVRController>;
  14884. /**
  14885. * Emits an event when a controller is attached.
  14886. */
  14887. onControllersAttachedObservable: Observable<WebVRController[]>;
  14888. /**
  14889. * Emits an event when a controller's mesh has been loaded;
  14890. */
  14891. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14892. /**
  14893. * Emits an event when the HMD's pose has been updated.
  14894. */
  14895. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14896. private _poseSet;
  14897. /**
  14898. * If the rig cameras be used as parent instead of this camera.
  14899. */
  14900. rigParenting: boolean;
  14901. private _lightOnControllers;
  14902. private _defaultHeight?;
  14903. /**
  14904. * Instantiates a WebVRFreeCamera.
  14905. * @param name The name of the WebVRFreeCamera
  14906. * @param position The starting anchor position for the camera
  14907. * @param scene The scene the camera belongs to
  14908. * @param webVROptions a set of customizable options for the webVRCamera
  14909. */
  14910. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14911. /**
  14912. * Gets the device distance from the ground in meters.
  14913. * @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.
  14914. */
  14915. deviceDistanceToRoomGround(): number;
  14916. /**
  14917. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14918. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14919. */
  14920. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14921. /**
  14922. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14923. * @returns A promise with a boolean set to if the standing matrix is supported.
  14924. */
  14925. useStandingMatrixAsync(): Promise<boolean>;
  14926. /**
  14927. * Disposes the camera
  14928. */
  14929. dispose(): void;
  14930. /**
  14931. * Gets a vrController by name.
  14932. * @param name The name of the controller to retreive
  14933. * @returns the controller matching the name specified or null if not found
  14934. */
  14935. getControllerByName(name: string): Nullable<WebVRController>;
  14936. private _leftController;
  14937. /**
  14938. * The controller corresponding to the users left hand.
  14939. */
  14940. readonly leftController: Nullable<WebVRController>;
  14941. private _rightController;
  14942. /**
  14943. * The controller corresponding to the users right hand.
  14944. */
  14945. readonly rightController: Nullable<WebVRController>;
  14946. /**
  14947. * Casts a ray forward from the vrCamera's gaze.
  14948. * @param length Length of the ray (default: 100)
  14949. * @returns the ray corresponding to the gaze
  14950. */
  14951. getForwardRay(length?: number): Ray;
  14952. /**
  14953. * @hidden
  14954. * Updates the camera based on device's frame data
  14955. */
  14956. _checkInputs(): void;
  14957. /**
  14958. * Updates the poseControlled values based on the input device pose.
  14959. * @param poseData Pose coming from the device
  14960. */
  14961. updateFromDevice(poseData: DevicePose): void;
  14962. private _htmlElementAttached;
  14963. private _detachIfAttached;
  14964. /**
  14965. * WebVR's attach control will start broadcasting frames to the device.
  14966. * Note that in certain browsers (chrome for example) this function must be called
  14967. * within a user-interaction callback. Example:
  14968. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14969. *
  14970. * @param element html element to attach the vrDevice to
  14971. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14972. */
  14973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14974. /**
  14975. * Detaches the camera from the html element and disables VR
  14976. *
  14977. * @param element html element to detach from
  14978. */
  14979. detachControl(element: HTMLElement): void;
  14980. /**
  14981. * @returns the name of this class
  14982. */
  14983. getClassName(): string;
  14984. /**
  14985. * Calls resetPose on the vrDisplay
  14986. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14987. */
  14988. resetToCurrentRotation(): void;
  14989. /**
  14990. * @hidden
  14991. * Updates the rig cameras (left and right eye)
  14992. */
  14993. _updateRigCameras(): void;
  14994. private _workingVector;
  14995. private _oneVector;
  14996. private _workingMatrix;
  14997. private updateCacheCalled;
  14998. private _correctPositionIfNotTrackPosition;
  14999. /**
  15000. * @hidden
  15001. * Updates the cached values of the camera
  15002. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15003. */
  15004. _updateCache(ignoreParentClass?: boolean): void;
  15005. /**
  15006. * @hidden
  15007. * Get current device position in babylon world
  15008. */
  15009. _computeDevicePosition(): void;
  15010. /**
  15011. * Updates the current device position and rotation in the babylon world
  15012. */
  15013. update(): void;
  15014. /**
  15015. * @hidden
  15016. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15017. * @returns an identity matrix
  15018. */
  15019. _getViewMatrix(): Matrix;
  15020. private _tmpMatrix;
  15021. /**
  15022. * This function is called by the two RIG cameras.
  15023. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15024. * @hidden
  15025. */
  15026. _getWebVRViewMatrix(): Matrix;
  15027. /** @hidden */
  15028. _getWebVRProjectionMatrix(): Matrix;
  15029. private _onGamepadConnectedObserver;
  15030. private _onGamepadDisconnectedObserver;
  15031. private _updateCacheWhenTrackingDisabledObserver;
  15032. /**
  15033. * Initializes the controllers and their meshes
  15034. */
  15035. initControllers(): void;
  15036. }
  15037. }
  15038. declare module BABYLON {
  15039. /**
  15040. * Size options for a post process
  15041. */
  15042. export type PostProcessOptions = {
  15043. width: number;
  15044. height: number;
  15045. };
  15046. /**
  15047. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15048. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15049. */
  15050. export class PostProcess {
  15051. /** Name of the PostProcess. */
  15052. name: string;
  15053. /**
  15054. * Gets or sets the unique id of the post process
  15055. */
  15056. uniqueId: number;
  15057. /**
  15058. * Width of the texture to apply the post process on
  15059. */
  15060. width: number;
  15061. /**
  15062. * Height of the texture to apply the post process on
  15063. */
  15064. height: number;
  15065. /**
  15066. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15067. * @hidden
  15068. */
  15069. _outputTexture: Nullable<InternalTexture>;
  15070. /**
  15071. * Sampling mode used by the shader
  15072. * See https://doc.babylonjs.com/classes/3.1/texture
  15073. */
  15074. renderTargetSamplingMode: number;
  15075. /**
  15076. * Clear color to use when screen clearing
  15077. */
  15078. clearColor: Color4;
  15079. /**
  15080. * If the buffer needs to be cleared before applying the post process. (default: true)
  15081. * Should be set to false if shader will overwrite all previous pixels.
  15082. */
  15083. autoClear: boolean;
  15084. /**
  15085. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15086. */
  15087. alphaMode: number;
  15088. /**
  15089. * Sets the setAlphaBlendConstants of the babylon engine
  15090. */
  15091. alphaConstants: Color4;
  15092. /**
  15093. * Animations to be used for the post processing
  15094. */
  15095. animations: Animation[];
  15096. /**
  15097. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15098. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15099. */
  15100. enablePixelPerfectMode: boolean;
  15101. /**
  15102. * Force the postprocess to be applied without taking in account viewport
  15103. */
  15104. forceFullscreenViewport: boolean;
  15105. /**
  15106. * List of inspectable custom properties (used by the Inspector)
  15107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15108. */
  15109. inspectableCustomProperties: IInspectable[];
  15110. /**
  15111. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15112. *
  15113. * | Value | Type | Description |
  15114. * | ----- | ----------------------------------- | ----------- |
  15115. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15116. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15117. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15118. *
  15119. */
  15120. scaleMode: number;
  15121. /**
  15122. * Force textures to be a power of two (default: false)
  15123. */
  15124. alwaysForcePOT: boolean;
  15125. private _samples;
  15126. /**
  15127. * Number of sample textures (default: 1)
  15128. */
  15129. samples: number;
  15130. /**
  15131. * Modify the scale of the post process to be the same as the viewport (default: false)
  15132. */
  15133. adaptScaleToCurrentViewport: boolean;
  15134. private _camera;
  15135. private _scene;
  15136. private _engine;
  15137. private _options;
  15138. private _reusable;
  15139. private _textureType;
  15140. /**
  15141. * Smart array of input and output textures for the post process.
  15142. * @hidden
  15143. */
  15144. _textures: SmartArray<InternalTexture>;
  15145. /**
  15146. * The index in _textures that corresponds to the output texture.
  15147. * @hidden
  15148. */
  15149. _currentRenderTextureInd: number;
  15150. private _effect;
  15151. private _samplers;
  15152. private _fragmentUrl;
  15153. private _vertexUrl;
  15154. private _parameters;
  15155. private _scaleRatio;
  15156. protected _indexParameters: any;
  15157. private _shareOutputWithPostProcess;
  15158. private _texelSize;
  15159. private _forcedOutputTexture;
  15160. /**
  15161. * Returns the fragment url or shader name used in the post process.
  15162. * @returns the fragment url or name in the shader store.
  15163. */
  15164. getEffectName(): string;
  15165. /**
  15166. * An event triggered when the postprocess is activated.
  15167. */
  15168. onActivateObservable: Observable<Camera>;
  15169. private _onActivateObserver;
  15170. /**
  15171. * A function that is added to the onActivateObservable
  15172. */
  15173. onActivate: Nullable<(camera: Camera) => void>;
  15174. /**
  15175. * An event triggered when the postprocess changes its size.
  15176. */
  15177. onSizeChangedObservable: Observable<PostProcess>;
  15178. private _onSizeChangedObserver;
  15179. /**
  15180. * A function that is added to the onSizeChangedObservable
  15181. */
  15182. onSizeChanged: (postProcess: PostProcess) => void;
  15183. /**
  15184. * An event triggered when the postprocess applies its effect.
  15185. */
  15186. onApplyObservable: Observable<Effect>;
  15187. private _onApplyObserver;
  15188. /**
  15189. * A function that is added to the onApplyObservable
  15190. */
  15191. onApply: (effect: Effect) => void;
  15192. /**
  15193. * An event triggered before rendering the postprocess
  15194. */
  15195. onBeforeRenderObservable: Observable<Effect>;
  15196. private _onBeforeRenderObserver;
  15197. /**
  15198. * A function that is added to the onBeforeRenderObservable
  15199. */
  15200. onBeforeRender: (effect: Effect) => void;
  15201. /**
  15202. * An event triggered after rendering the postprocess
  15203. */
  15204. onAfterRenderObservable: Observable<Effect>;
  15205. private _onAfterRenderObserver;
  15206. /**
  15207. * A function that is added to the onAfterRenderObservable
  15208. */
  15209. onAfterRender: (efect: Effect) => void;
  15210. /**
  15211. * 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
  15212. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15213. */
  15214. inputTexture: InternalTexture;
  15215. /**
  15216. * Gets the camera which post process is applied to.
  15217. * @returns The camera the post process is applied to.
  15218. */
  15219. getCamera(): Camera;
  15220. /**
  15221. * Gets the texel size of the postprocess.
  15222. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15223. */
  15224. readonly texelSize: Vector2;
  15225. /**
  15226. * Creates a new instance PostProcess
  15227. * @param name The name of the PostProcess.
  15228. * @param fragmentUrl The url of the fragment shader to be used.
  15229. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15230. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15231. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15232. * @param camera The camera to apply the render pass to.
  15233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15234. * @param engine The engine which the post process will be applied. (default: current engine)
  15235. * @param reusable If the post process can be reused on the same frame. (default: false)
  15236. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15237. * @param textureType Type of textures used when performing the post process. (default: 0)
  15238. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15239. * @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
  15240. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15241. */
  15242. constructor(
  15243. /** Name of the PostProcess. */
  15244. 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);
  15245. /**
  15246. * Gets a string idenfifying the name of the class
  15247. * @returns "PostProcess" string
  15248. */
  15249. getClassName(): string;
  15250. /**
  15251. * Gets the engine which this post process belongs to.
  15252. * @returns The engine the post process was enabled with.
  15253. */
  15254. getEngine(): Engine;
  15255. /**
  15256. * The effect that is created when initializing the post process.
  15257. * @returns The created effect corresponding the the postprocess.
  15258. */
  15259. getEffect(): Effect;
  15260. /**
  15261. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15262. * @param postProcess The post process to share the output with.
  15263. * @returns This post process.
  15264. */
  15265. shareOutputWith(postProcess: PostProcess): PostProcess;
  15266. /**
  15267. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15268. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15269. */
  15270. useOwnOutput(): void;
  15271. /**
  15272. * Updates the effect with the current post process compile time values and recompiles the shader.
  15273. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15274. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15275. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15276. * @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
  15277. * @param onCompiled Called when the shader has been compiled.
  15278. * @param onError Called if there is an error when compiling a shader.
  15279. */
  15280. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15281. /**
  15282. * The post process is reusable if it can be used multiple times within one frame.
  15283. * @returns If the post process is reusable
  15284. */
  15285. isReusable(): boolean;
  15286. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15287. markTextureDirty(): void;
  15288. /**
  15289. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15290. * 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.
  15291. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15292. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15293. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15294. * @returns The target texture that was bound to be written to.
  15295. */
  15296. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15297. /**
  15298. * If the post process is supported.
  15299. */
  15300. readonly isSupported: boolean;
  15301. /**
  15302. * The aspect ratio of the output texture.
  15303. */
  15304. readonly aspectRatio: number;
  15305. /**
  15306. * Get a value indicating if the post-process is ready to be used
  15307. * @returns true if the post-process is ready (shader is compiled)
  15308. */
  15309. isReady(): boolean;
  15310. /**
  15311. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15312. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15313. */
  15314. apply(): Nullable<Effect>;
  15315. private _disposeTextures;
  15316. /**
  15317. * Disposes the post process.
  15318. * @param camera The camera to dispose the post process on.
  15319. */
  15320. dispose(camera?: Camera): void;
  15321. }
  15322. }
  15323. declare module BABYLON {
  15324. /** @hidden */
  15325. export var kernelBlurVaryingDeclaration: {
  15326. name: string;
  15327. shader: string;
  15328. };
  15329. }
  15330. declare module BABYLON {
  15331. /** @hidden */
  15332. export var kernelBlurFragment: {
  15333. name: string;
  15334. shader: string;
  15335. };
  15336. }
  15337. declare module BABYLON {
  15338. /** @hidden */
  15339. export var kernelBlurFragment2: {
  15340. name: string;
  15341. shader: string;
  15342. };
  15343. }
  15344. declare module BABYLON {
  15345. /** @hidden */
  15346. export var kernelBlurPixelShader: {
  15347. name: string;
  15348. shader: string;
  15349. };
  15350. }
  15351. declare module BABYLON {
  15352. /** @hidden */
  15353. export var kernelBlurVertex: {
  15354. name: string;
  15355. shader: string;
  15356. };
  15357. }
  15358. declare module BABYLON {
  15359. /** @hidden */
  15360. export var kernelBlurVertexShader: {
  15361. name: string;
  15362. shader: string;
  15363. };
  15364. }
  15365. declare module BABYLON {
  15366. /**
  15367. * The Blur Post Process which blurs an image based on a kernel and direction.
  15368. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15369. */
  15370. export class BlurPostProcess extends PostProcess {
  15371. /** The direction in which to blur the image. */
  15372. direction: Vector2;
  15373. private blockCompilation;
  15374. protected _kernel: number;
  15375. protected _idealKernel: number;
  15376. protected _packedFloat: boolean;
  15377. private _staticDefines;
  15378. /**
  15379. * Sets the length in pixels of the blur sample region
  15380. */
  15381. /**
  15382. * Gets the length in pixels of the blur sample region
  15383. */
  15384. kernel: number;
  15385. /**
  15386. * Sets wether or not the blur needs to unpack/repack floats
  15387. */
  15388. /**
  15389. * Gets wether or not the blur is unpacking/repacking floats
  15390. */
  15391. packedFloat: boolean;
  15392. /**
  15393. * Creates a new instance BlurPostProcess
  15394. * @param name The name of the effect.
  15395. * @param direction The direction in which to blur the image.
  15396. * @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.
  15397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15398. * @param camera The camera to apply the render pass to.
  15399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15400. * @param engine The engine which the post process will be applied. (default: current engine)
  15401. * @param reusable If the post process can be reused on the same frame. (default: false)
  15402. * @param textureType Type of textures used when performing the post process. (default: 0)
  15403. * @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)
  15404. */
  15405. constructor(name: string,
  15406. /** The direction in which to blur the image. */
  15407. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15408. /**
  15409. * Updates the effect with the current post process compile time values and recompiles the shader.
  15410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15413. * @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
  15414. * @param onCompiled Called when the shader has been compiled.
  15415. * @param onError Called if there is an error when compiling a shader.
  15416. */
  15417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15418. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15419. /**
  15420. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15421. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15422. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15423. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15424. * The gaps between physical kernels are compensated for in the weighting of the samples
  15425. * @param idealKernel Ideal blur kernel.
  15426. * @return Nearest best kernel.
  15427. */
  15428. protected _nearestBestKernel(idealKernel: number): number;
  15429. /**
  15430. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15431. * @param x The point on the Gaussian distribution to sample.
  15432. * @return the value of the Gaussian function at x.
  15433. */
  15434. protected _gaussianWeight(x: number): number;
  15435. /**
  15436. * Generates a string that can be used as a floating point number in GLSL.
  15437. * @param x Value to print.
  15438. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15439. * @return GLSL float string.
  15440. */
  15441. protected _glslFloat(x: number, decimalFigures?: number): string;
  15442. }
  15443. }
  15444. declare module BABYLON {
  15445. /**
  15446. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15447. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15448. * You can then easily use it as a reflectionTexture on a flat surface.
  15449. * In case the surface is not a plane, please consider relying on reflection probes.
  15450. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15451. */
  15452. export class MirrorTexture extends RenderTargetTexture {
  15453. private scene;
  15454. /**
  15455. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15456. * 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.
  15457. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15458. */
  15459. mirrorPlane: Plane;
  15460. /**
  15461. * Define the blur ratio used to blur the reflection if needed.
  15462. */
  15463. blurRatio: number;
  15464. /**
  15465. * Define the adaptive blur kernel used to blur the reflection if needed.
  15466. * This will autocompute the closest best match for the `blurKernel`
  15467. */
  15468. adaptiveBlurKernel: number;
  15469. /**
  15470. * Define the blur kernel used to blur the reflection if needed.
  15471. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15472. */
  15473. blurKernel: number;
  15474. /**
  15475. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15476. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15477. */
  15478. blurKernelX: number;
  15479. /**
  15480. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15481. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15482. */
  15483. blurKernelY: number;
  15484. private _autoComputeBlurKernel;
  15485. protected _onRatioRescale(): void;
  15486. private _updateGammaSpace;
  15487. private _imageProcessingConfigChangeObserver;
  15488. private _transformMatrix;
  15489. private _mirrorMatrix;
  15490. private _savedViewMatrix;
  15491. private _blurX;
  15492. private _blurY;
  15493. private _adaptiveBlurKernel;
  15494. private _blurKernelX;
  15495. private _blurKernelY;
  15496. private _blurRatio;
  15497. /**
  15498. * Instantiates a Mirror Texture.
  15499. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15500. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15501. * You can then easily use it as a reflectionTexture on a flat surface.
  15502. * In case the surface is not a plane, please consider relying on reflection probes.
  15503. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15504. * @param name
  15505. * @param size
  15506. * @param scene
  15507. * @param generateMipMaps
  15508. * @param type
  15509. * @param samplingMode
  15510. * @param generateDepthBuffer
  15511. */
  15512. constructor(name: string, size: number | {
  15513. width: number;
  15514. height: number;
  15515. } | {
  15516. ratio: number;
  15517. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15518. private _preparePostProcesses;
  15519. /**
  15520. * Clone the mirror texture.
  15521. * @returns the cloned texture
  15522. */
  15523. clone(): MirrorTexture;
  15524. /**
  15525. * Serialize the texture to a JSON representation you could use in Parse later on
  15526. * @returns the serialized JSON representation
  15527. */
  15528. serialize(): any;
  15529. /**
  15530. * Dispose the texture and release its associated resources.
  15531. */
  15532. dispose(): void;
  15533. }
  15534. }
  15535. declare module BABYLON {
  15536. /**
  15537. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15538. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15539. */
  15540. export class Texture extends BaseTexture {
  15541. /** @hidden */
  15542. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15543. /** @hidden */
  15544. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15545. /** @hidden */
  15546. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15547. /** nearest is mag = nearest and min = nearest and mip = linear */
  15548. static readonly NEAREST_SAMPLINGMODE: number;
  15549. /** nearest is mag = nearest and min = nearest and mip = linear */
  15550. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15552. static readonly BILINEAR_SAMPLINGMODE: number;
  15553. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15554. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15555. /** Trilinear is mag = linear and min = linear and mip = linear */
  15556. static readonly TRILINEAR_SAMPLINGMODE: number;
  15557. /** Trilinear is mag = linear and min = linear and mip = linear */
  15558. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15559. /** mag = nearest and min = nearest and mip = nearest */
  15560. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15561. /** mag = nearest and min = linear and mip = nearest */
  15562. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15563. /** mag = nearest and min = linear and mip = linear */
  15564. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15565. /** mag = nearest and min = linear and mip = none */
  15566. static readonly NEAREST_LINEAR: number;
  15567. /** mag = nearest and min = nearest and mip = none */
  15568. static readonly NEAREST_NEAREST: number;
  15569. /** mag = linear and min = nearest and mip = nearest */
  15570. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15571. /** mag = linear and min = nearest and mip = linear */
  15572. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15573. /** mag = linear and min = linear and mip = none */
  15574. static readonly LINEAR_LINEAR: number;
  15575. /** mag = linear and min = nearest and mip = none */
  15576. static readonly LINEAR_NEAREST: number;
  15577. /** Explicit coordinates mode */
  15578. static readonly EXPLICIT_MODE: number;
  15579. /** Spherical coordinates mode */
  15580. static readonly SPHERICAL_MODE: number;
  15581. /** Planar coordinates mode */
  15582. static readonly PLANAR_MODE: number;
  15583. /** Cubic coordinates mode */
  15584. static readonly CUBIC_MODE: number;
  15585. /** Projection coordinates mode */
  15586. static readonly PROJECTION_MODE: number;
  15587. /** Inverse Cubic coordinates mode */
  15588. static readonly SKYBOX_MODE: number;
  15589. /** Inverse Cubic coordinates mode */
  15590. static readonly INVCUBIC_MODE: number;
  15591. /** Equirectangular coordinates mode */
  15592. static readonly EQUIRECTANGULAR_MODE: number;
  15593. /** Equirectangular Fixed coordinates mode */
  15594. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15595. /** Equirectangular Fixed Mirrored coordinates mode */
  15596. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15597. /** Texture is not repeating outside of 0..1 UVs */
  15598. static readonly CLAMP_ADDRESSMODE: number;
  15599. /** Texture is repeating outside of 0..1 UVs */
  15600. static readonly WRAP_ADDRESSMODE: number;
  15601. /** Texture is repeating and mirrored */
  15602. static readonly MIRROR_ADDRESSMODE: number;
  15603. /**
  15604. * 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
  15605. */
  15606. static UseSerializedUrlIfAny: boolean;
  15607. /**
  15608. * Define the url of the texture.
  15609. */
  15610. url: Nullable<string>;
  15611. /**
  15612. * Define an offset on the texture to offset the u coordinates of the UVs
  15613. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15614. */
  15615. uOffset: number;
  15616. /**
  15617. * Define an offset on the texture to offset the v coordinates of the UVs
  15618. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15619. */
  15620. vOffset: number;
  15621. /**
  15622. * Define an offset on the texture to scale the u coordinates of the UVs
  15623. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15624. */
  15625. uScale: number;
  15626. /**
  15627. * Define an offset on the texture to scale the v coordinates of the UVs
  15628. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15629. */
  15630. vScale: number;
  15631. /**
  15632. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15633. * @see http://doc.babylonjs.com/how_to/more_materials
  15634. */
  15635. uAng: number;
  15636. /**
  15637. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15638. * @see http://doc.babylonjs.com/how_to/more_materials
  15639. */
  15640. vAng: number;
  15641. /**
  15642. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15643. * @see http://doc.babylonjs.com/how_to/more_materials
  15644. */
  15645. wAng: number;
  15646. /**
  15647. * Defines the center of rotation (U)
  15648. */
  15649. uRotationCenter: number;
  15650. /**
  15651. * Defines the center of rotation (V)
  15652. */
  15653. vRotationCenter: number;
  15654. /**
  15655. * Defines the center of rotation (W)
  15656. */
  15657. wRotationCenter: number;
  15658. /**
  15659. * Are mip maps generated for this texture or not.
  15660. */
  15661. readonly noMipmap: boolean;
  15662. /**
  15663. * List of inspectable custom properties (used by the Inspector)
  15664. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15665. */
  15666. inspectableCustomProperties: Nullable<IInspectable[]>;
  15667. private _noMipmap;
  15668. /** @hidden */
  15669. _invertY: boolean;
  15670. private _rowGenerationMatrix;
  15671. private _cachedTextureMatrix;
  15672. private _projectionModeMatrix;
  15673. private _t0;
  15674. private _t1;
  15675. private _t2;
  15676. private _cachedUOffset;
  15677. private _cachedVOffset;
  15678. private _cachedUScale;
  15679. private _cachedVScale;
  15680. private _cachedUAng;
  15681. private _cachedVAng;
  15682. private _cachedWAng;
  15683. private _cachedProjectionMatrixId;
  15684. private _cachedCoordinatesMode;
  15685. /** @hidden */
  15686. protected _initialSamplingMode: number;
  15687. /** @hidden */
  15688. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15689. private _deleteBuffer;
  15690. protected _format: Nullable<number>;
  15691. private _delayedOnLoad;
  15692. private _delayedOnError;
  15693. /**
  15694. * Observable triggered once the texture has been loaded.
  15695. */
  15696. onLoadObservable: Observable<Texture>;
  15697. protected _isBlocking: boolean;
  15698. /**
  15699. * Is the texture preventing material to render while loading.
  15700. * If false, a default texture will be used instead of the loading one during the preparation step.
  15701. */
  15702. isBlocking: boolean;
  15703. /**
  15704. * Get the current sampling mode associated with the texture.
  15705. */
  15706. readonly samplingMode: number;
  15707. /**
  15708. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15709. */
  15710. readonly invertY: boolean;
  15711. /**
  15712. * Instantiates a new texture.
  15713. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15714. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15715. * @param url define the url of the picture to load as a texture
  15716. * @param scene define the scene or engine the texture will belong to
  15717. * @param noMipmap define if the texture will require mip maps or not
  15718. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15719. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15720. * @param onLoad define a callback triggered when the texture has been loaded
  15721. * @param onError define a callback triggered when an error occurred during the loading session
  15722. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15723. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15724. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15725. */
  15726. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15727. /**
  15728. * Update the url (and optional buffer) of this texture if url was null during construction.
  15729. * @param url the url of the texture
  15730. * @param buffer the buffer of the texture (defaults to null)
  15731. * @param onLoad callback called when the texture is loaded (defaults to null)
  15732. */
  15733. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15734. /**
  15735. * Finish the loading sequence of a texture flagged as delayed load.
  15736. * @hidden
  15737. */
  15738. delayLoad(): void;
  15739. private _prepareRowForTextureGeneration;
  15740. /**
  15741. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15742. * @returns the transform matrix of the texture.
  15743. */
  15744. getTextureMatrix(): Matrix;
  15745. /**
  15746. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15747. * @returns The reflection texture transform
  15748. */
  15749. getReflectionTextureMatrix(): Matrix;
  15750. /**
  15751. * Clones the texture.
  15752. * @returns the cloned texture
  15753. */
  15754. clone(): Texture;
  15755. /**
  15756. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15757. * @returns The JSON representation of the texture
  15758. */
  15759. serialize(): any;
  15760. /**
  15761. * Get the current class name of the texture useful for serialization or dynamic coding.
  15762. * @returns "Texture"
  15763. */
  15764. getClassName(): string;
  15765. /**
  15766. * Dispose the texture and release its associated resources.
  15767. */
  15768. dispose(): void;
  15769. /**
  15770. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15771. * @param parsedTexture Define the JSON representation of the texture
  15772. * @param scene Define the scene the parsed texture should be instantiated in
  15773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15774. * @returns The parsed texture if successful
  15775. */
  15776. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15777. /**
  15778. * Creates a texture from its base 64 representation.
  15779. * @param data Define the base64 payload without the data: prefix
  15780. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15781. * @param scene Define the scene the texture should belong to
  15782. * @param noMipmap Forces the texture to not create mip map information if true
  15783. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15784. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15785. * @param onLoad define a callback triggered when the texture has been loaded
  15786. * @param onError define a callback triggered when an error occurred during the loading session
  15787. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15788. * @returns the created texture
  15789. */
  15790. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15791. /**
  15792. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15793. * @param data Define the base64 payload without the data: prefix
  15794. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15795. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15796. * @param scene Define the scene the texture should belong to
  15797. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15798. * @param noMipmap Forces the texture to not create mip map information if true
  15799. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15800. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15801. * @param onLoad define a callback triggered when the texture has been loaded
  15802. * @param onError define a callback triggered when an error occurred during the loading session
  15803. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15804. * @returns the created texture
  15805. */
  15806. 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;
  15807. }
  15808. }
  15809. declare module BABYLON {
  15810. /**
  15811. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15812. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15813. */
  15814. export class PostProcessManager {
  15815. private _scene;
  15816. private _indexBuffer;
  15817. private _vertexBuffers;
  15818. /**
  15819. * Creates a new instance PostProcess
  15820. * @param scene The scene that the post process is associated with.
  15821. */
  15822. constructor(scene: Scene);
  15823. private _prepareBuffers;
  15824. private _buildIndexBuffer;
  15825. /**
  15826. * Rebuilds the vertex buffers of the manager.
  15827. * @hidden
  15828. */
  15829. _rebuild(): void;
  15830. /**
  15831. * Prepares a frame to be run through a post process.
  15832. * @param sourceTexture The input texture to the post procesess. (default: null)
  15833. * @param postProcesses An array of post processes to be run. (default: null)
  15834. * @returns True if the post processes were able to be run.
  15835. * @hidden
  15836. */
  15837. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15838. /**
  15839. * Manually render a set of post processes to a texture.
  15840. * @param postProcesses An array of post processes to be run.
  15841. * @param targetTexture The target texture to render to.
  15842. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15843. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15844. * @param lodLevel defines which lod of the texture to render to
  15845. */
  15846. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15847. /**
  15848. * Finalize the result of the output of the postprocesses.
  15849. * @param doNotPresent If true the result will not be displayed to the screen.
  15850. * @param targetTexture The target texture to render to.
  15851. * @param faceIndex The index of the face to bind the target texture to.
  15852. * @param postProcesses The array of post processes to render.
  15853. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15854. * @hidden
  15855. */
  15856. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15857. /**
  15858. * Disposes of the post process manager.
  15859. */
  15860. dispose(): void;
  15861. }
  15862. }
  15863. declare module BABYLON {
  15864. /** Interface used by value gradients (color, factor, ...) */
  15865. export interface IValueGradient {
  15866. /**
  15867. * Gets or sets the gradient value (between 0 and 1)
  15868. */
  15869. gradient: number;
  15870. }
  15871. /** Class used to store color4 gradient */
  15872. export class ColorGradient implements IValueGradient {
  15873. /**
  15874. * Gets or sets the gradient value (between 0 and 1)
  15875. */
  15876. gradient: number;
  15877. /**
  15878. * Gets or sets first associated color
  15879. */
  15880. color1: Color4;
  15881. /**
  15882. * Gets or sets second associated color
  15883. */
  15884. color2?: Color4;
  15885. /**
  15886. * Will get a color picked randomly between color1 and color2.
  15887. * If color2 is undefined then color1 will be used
  15888. * @param result defines the target Color4 to store the result in
  15889. */
  15890. getColorToRef(result: Color4): void;
  15891. }
  15892. /** Class used to store color 3 gradient */
  15893. export class Color3Gradient implements IValueGradient {
  15894. /**
  15895. * Gets or sets the gradient value (between 0 and 1)
  15896. */
  15897. gradient: number;
  15898. /**
  15899. * Gets or sets the associated color
  15900. */
  15901. color: Color3;
  15902. }
  15903. /** Class used to store factor gradient */
  15904. export class FactorGradient implements IValueGradient {
  15905. /**
  15906. * Gets or sets the gradient value (between 0 and 1)
  15907. */
  15908. gradient: number;
  15909. /**
  15910. * Gets or sets first associated factor
  15911. */
  15912. factor1: number;
  15913. /**
  15914. * Gets or sets second associated factor
  15915. */
  15916. factor2?: number;
  15917. /**
  15918. * Will get a number picked randomly between factor1 and factor2.
  15919. * If factor2 is undefined then factor1 will be used
  15920. * @returns the picked number
  15921. */
  15922. getFactor(): number;
  15923. }
  15924. /**
  15925. * Helper used to simplify some generic gradient tasks
  15926. */
  15927. export class GradientHelper {
  15928. /**
  15929. * Gets the current gradient from an array of IValueGradient
  15930. * @param ratio defines the current ratio to get
  15931. * @param gradients defines the array of IValueGradient
  15932. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15933. */
  15934. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15935. }
  15936. }
  15937. declare module BABYLON {
  15938. interface AbstractScene {
  15939. /**
  15940. * The list of procedural textures added to the scene
  15941. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15942. */
  15943. proceduralTextures: Array<ProceduralTexture>;
  15944. }
  15945. /**
  15946. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15947. * in a given scene.
  15948. */
  15949. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15950. /**
  15951. * The component name helpfull to identify the component in the list of scene components.
  15952. */
  15953. readonly name: string;
  15954. /**
  15955. * The scene the component belongs to.
  15956. */
  15957. scene: Scene;
  15958. /**
  15959. * Creates a new instance of the component for the given scene
  15960. * @param scene Defines the scene to register the component in
  15961. */
  15962. constructor(scene: Scene);
  15963. /**
  15964. * Registers the component in a given scene
  15965. */
  15966. register(): void;
  15967. /**
  15968. * Rebuilds the elements related to this component in case of
  15969. * context lost for instance.
  15970. */
  15971. rebuild(): void;
  15972. /**
  15973. * Disposes the component and the associated ressources.
  15974. */
  15975. dispose(): void;
  15976. private _beforeClear;
  15977. }
  15978. }
  15979. declare module BABYLON {
  15980. interface Engine {
  15981. /**
  15982. * Creates a new render target cube texture
  15983. * @param size defines the size of the texture
  15984. * @param options defines the options used to create the texture
  15985. * @returns a new render target cube texture stored in an InternalTexture
  15986. */
  15987. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15988. }
  15989. }
  15990. declare module BABYLON {
  15991. /** @hidden */
  15992. export var proceduralVertexShader: {
  15993. name: string;
  15994. shader: string;
  15995. };
  15996. }
  15997. declare module BABYLON {
  15998. /**
  15999. * 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.
  16000. * This is the base class of any Procedural texture and contains most of the shareable code.
  16001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16002. */
  16003. export class ProceduralTexture extends Texture {
  16004. isCube: boolean;
  16005. /**
  16006. * Define if the texture is enabled or not (disabled texture will not render)
  16007. */
  16008. isEnabled: boolean;
  16009. /**
  16010. * Define if the texture must be cleared before rendering (default is true)
  16011. */
  16012. autoClear: boolean;
  16013. /**
  16014. * Callback called when the texture is generated
  16015. */
  16016. onGenerated: () => void;
  16017. /**
  16018. * Event raised when the texture is generated
  16019. */
  16020. onGeneratedObservable: Observable<ProceduralTexture>;
  16021. /** @hidden */
  16022. _generateMipMaps: boolean;
  16023. /** @hidden **/
  16024. _effect: Effect;
  16025. /** @hidden */
  16026. _textures: {
  16027. [key: string]: Texture;
  16028. };
  16029. private _size;
  16030. private _currentRefreshId;
  16031. private _refreshRate;
  16032. private _vertexBuffers;
  16033. private _indexBuffer;
  16034. private _uniforms;
  16035. private _samplers;
  16036. private _fragment;
  16037. private _floats;
  16038. private _ints;
  16039. private _floatsArrays;
  16040. private _colors3;
  16041. private _colors4;
  16042. private _vectors2;
  16043. private _vectors3;
  16044. private _matrices;
  16045. private _fallbackTexture;
  16046. private _fallbackTextureUsed;
  16047. private _engine;
  16048. private _cachedDefines;
  16049. private _contentUpdateId;
  16050. private _contentData;
  16051. /**
  16052. * Instantiates a new procedural texture.
  16053. * 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.
  16054. * This is the base class of any Procedural texture and contains most of the shareable code.
  16055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16056. * @param name Define the name of the texture
  16057. * @param size Define the size of the texture to create
  16058. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16059. * @param scene Define the scene the texture belongs to
  16060. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16061. * @param generateMipMaps Define if the texture should creates mip maps or not
  16062. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16063. */
  16064. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16065. /**
  16066. * The effect that is created when initializing the post process.
  16067. * @returns The created effect corresponding the the postprocess.
  16068. */
  16069. getEffect(): Effect;
  16070. /**
  16071. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16072. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16073. */
  16074. getContent(): Nullable<ArrayBufferView>;
  16075. private _createIndexBuffer;
  16076. /** @hidden */
  16077. _rebuild(): void;
  16078. /**
  16079. * Resets the texture in order to recreate its associated resources.
  16080. * This can be called in case of context loss
  16081. */
  16082. reset(): void;
  16083. protected _getDefines(): string;
  16084. /**
  16085. * Is the texture ready to be used ? (rendered at least once)
  16086. * @returns true if ready, otherwise, false.
  16087. */
  16088. isReady(): boolean;
  16089. /**
  16090. * Resets the refresh counter of the texture and start bak from scratch.
  16091. * Could be useful to regenerate the texture if it is setup to render only once.
  16092. */
  16093. resetRefreshCounter(): void;
  16094. /**
  16095. * Set the fragment shader to use in order to render the texture.
  16096. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16097. */
  16098. setFragment(fragment: any): void;
  16099. /**
  16100. * Define the refresh rate of the texture or the rendering frequency.
  16101. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16102. */
  16103. refreshRate: number;
  16104. /** @hidden */
  16105. _shouldRender(): boolean;
  16106. /**
  16107. * Get the size the texture is rendering at.
  16108. * @returns the size (texture is always squared)
  16109. */
  16110. getRenderSize(): number;
  16111. /**
  16112. * Resize the texture to new value.
  16113. * @param size Define the new size the texture should have
  16114. * @param generateMipMaps Define whether the new texture should create mip maps
  16115. */
  16116. resize(size: number, generateMipMaps: boolean): void;
  16117. private _checkUniform;
  16118. /**
  16119. * Set a texture in the shader program used to render.
  16120. * @param name Define the name of the uniform samplers as defined in the shader
  16121. * @param texture Define the texture to bind to this sampler
  16122. * @return the texture itself allowing "fluent" like uniform updates
  16123. */
  16124. setTexture(name: string, texture: Texture): ProceduralTexture;
  16125. /**
  16126. * Set a float in the shader.
  16127. * @param name Define the name of the uniform as defined in the shader
  16128. * @param value Define the value to give to the uniform
  16129. * @return the texture itself allowing "fluent" like uniform updates
  16130. */
  16131. setFloat(name: string, value: number): ProceduralTexture;
  16132. /**
  16133. * Set a int in the shader.
  16134. * @param name Define the name of the uniform as defined in the shader
  16135. * @param value Define the value to give to the uniform
  16136. * @return the texture itself allowing "fluent" like uniform updates
  16137. */
  16138. setInt(name: string, value: number): ProceduralTexture;
  16139. /**
  16140. * Set an array of floats in the shader.
  16141. * @param name Define the name of the uniform as defined in the shader
  16142. * @param value Define the value to give to the uniform
  16143. * @return the texture itself allowing "fluent" like uniform updates
  16144. */
  16145. setFloats(name: string, value: number[]): ProceduralTexture;
  16146. /**
  16147. * Set a vec3 in the shader from a Color3.
  16148. * @param name Define the name of the uniform as defined in the shader
  16149. * @param value Define the value to give to the uniform
  16150. * @return the texture itself allowing "fluent" like uniform updates
  16151. */
  16152. setColor3(name: string, value: Color3): ProceduralTexture;
  16153. /**
  16154. * Set a vec4 in the shader from a Color4.
  16155. * @param name Define the name of the uniform as defined in the shader
  16156. * @param value Define the value to give to the uniform
  16157. * @return the texture itself allowing "fluent" like uniform updates
  16158. */
  16159. setColor4(name: string, value: Color4): ProceduralTexture;
  16160. /**
  16161. * Set a vec2 in the shader from a Vector2.
  16162. * @param name Define the name of the uniform as defined in the shader
  16163. * @param value Define the value to give to the uniform
  16164. * @return the texture itself allowing "fluent" like uniform updates
  16165. */
  16166. setVector2(name: string, value: Vector2): ProceduralTexture;
  16167. /**
  16168. * Set a vec3 in the shader from a Vector3.
  16169. * @param name Define the name of the uniform as defined in the shader
  16170. * @param value Define the value to give to the uniform
  16171. * @return the texture itself allowing "fluent" like uniform updates
  16172. */
  16173. setVector3(name: string, value: Vector3): ProceduralTexture;
  16174. /**
  16175. * Set a mat4 in the shader from a MAtrix.
  16176. * @param name Define the name of the uniform as defined in the shader
  16177. * @param value Define the value to give to the uniform
  16178. * @return the texture itself allowing "fluent" like uniform updates
  16179. */
  16180. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16181. /**
  16182. * Render the texture to its associated render target.
  16183. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16184. */
  16185. render(useCameraPostProcess?: boolean): void;
  16186. /**
  16187. * Clone the texture.
  16188. * @returns the cloned texture
  16189. */
  16190. clone(): ProceduralTexture;
  16191. /**
  16192. * Dispose the texture and release its asoociated resources.
  16193. */
  16194. dispose(): void;
  16195. }
  16196. }
  16197. declare module BABYLON {
  16198. /**
  16199. * This represents the base class for particle system in Babylon.
  16200. * 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.
  16201. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16202. * @example https://doc.babylonjs.com/babylon101/particles
  16203. */
  16204. export class BaseParticleSystem {
  16205. /**
  16206. * Source color is added to the destination color without alpha affecting the result
  16207. */
  16208. static BLENDMODE_ONEONE: number;
  16209. /**
  16210. * Blend current color and particle color using particle’s alpha
  16211. */
  16212. static BLENDMODE_STANDARD: number;
  16213. /**
  16214. * Add current color and particle color multiplied by particle’s alpha
  16215. */
  16216. static BLENDMODE_ADD: number;
  16217. /**
  16218. * Multiply current color with particle color
  16219. */
  16220. static BLENDMODE_MULTIPLY: number;
  16221. /**
  16222. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16223. */
  16224. static BLENDMODE_MULTIPLYADD: number;
  16225. /**
  16226. * List of animations used by the particle system.
  16227. */
  16228. animations: Animation[];
  16229. /**
  16230. * The id of the Particle system.
  16231. */
  16232. id: string;
  16233. /**
  16234. * The friendly name of the Particle system.
  16235. */
  16236. name: string;
  16237. /**
  16238. * The rendering group used by the Particle system to chose when to render.
  16239. */
  16240. renderingGroupId: number;
  16241. /**
  16242. * The emitter represents the Mesh or position we are attaching the particle system to.
  16243. */
  16244. emitter: Nullable<AbstractMesh | Vector3>;
  16245. /**
  16246. * The maximum number of particles to emit per frame
  16247. */
  16248. emitRate: number;
  16249. /**
  16250. * If you want to launch only a few particles at once, that can be done, as well.
  16251. */
  16252. manualEmitCount: number;
  16253. /**
  16254. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16255. */
  16256. updateSpeed: number;
  16257. /**
  16258. * The amount of time the particle system is running (depends of the overall update speed).
  16259. */
  16260. targetStopDuration: number;
  16261. /**
  16262. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16263. */
  16264. disposeOnStop: boolean;
  16265. /**
  16266. * Minimum power of emitting particles.
  16267. */
  16268. minEmitPower: number;
  16269. /**
  16270. * Maximum power of emitting particles.
  16271. */
  16272. maxEmitPower: number;
  16273. /**
  16274. * Minimum life time of emitting particles.
  16275. */
  16276. minLifeTime: number;
  16277. /**
  16278. * Maximum life time of emitting particles.
  16279. */
  16280. maxLifeTime: number;
  16281. /**
  16282. * Minimum Size of emitting particles.
  16283. */
  16284. minSize: number;
  16285. /**
  16286. * Maximum Size of emitting particles.
  16287. */
  16288. maxSize: number;
  16289. /**
  16290. * Minimum scale of emitting particles on X axis.
  16291. */
  16292. minScaleX: number;
  16293. /**
  16294. * Maximum scale of emitting particles on X axis.
  16295. */
  16296. maxScaleX: number;
  16297. /**
  16298. * Minimum scale of emitting particles on Y axis.
  16299. */
  16300. minScaleY: number;
  16301. /**
  16302. * Maximum scale of emitting particles on Y axis.
  16303. */
  16304. maxScaleY: number;
  16305. /**
  16306. * Gets or sets the minimal initial rotation in radians.
  16307. */
  16308. minInitialRotation: number;
  16309. /**
  16310. * Gets or sets the maximal initial rotation in radians.
  16311. */
  16312. maxInitialRotation: number;
  16313. /**
  16314. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16315. */
  16316. minAngularSpeed: number;
  16317. /**
  16318. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16319. */
  16320. maxAngularSpeed: number;
  16321. /**
  16322. * The texture used to render each particle. (this can be a spritesheet)
  16323. */
  16324. particleTexture: Nullable<Texture>;
  16325. /**
  16326. * The layer mask we are rendering the particles through.
  16327. */
  16328. layerMask: number;
  16329. /**
  16330. * This can help using your own shader to render the particle system.
  16331. * The according effect will be created
  16332. */
  16333. customShader: any;
  16334. /**
  16335. * By default particle system starts as soon as they are created. This prevents the
  16336. * automatic start to happen and let you decide when to start emitting particles.
  16337. */
  16338. preventAutoStart: boolean;
  16339. private _noiseTexture;
  16340. /**
  16341. * Gets or sets a texture used to add random noise to particle positions
  16342. */
  16343. noiseTexture: Nullable<ProceduralTexture>;
  16344. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16345. noiseStrength: Vector3;
  16346. /**
  16347. * Callback triggered when the particle animation is ending.
  16348. */
  16349. onAnimationEnd: Nullable<() => void>;
  16350. /**
  16351. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16352. */
  16353. blendMode: number;
  16354. /**
  16355. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16356. * to override the particles.
  16357. */
  16358. forceDepthWrite: boolean;
  16359. /** 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 */
  16360. preWarmCycles: number;
  16361. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16362. preWarmStepOffset: number;
  16363. /**
  16364. * 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)
  16365. */
  16366. spriteCellChangeSpeed: number;
  16367. /**
  16368. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16369. */
  16370. startSpriteCellID: number;
  16371. /**
  16372. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16373. */
  16374. endSpriteCellID: number;
  16375. /**
  16376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16377. */
  16378. spriteCellWidth: number;
  16379. /**
  16380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16381. */
  16382. spriteCellHeight: number;
  16383. /**
  16384. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16385. */
  16386. spriteRandomStartCell: boolean;
  16387. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16388. translationPivot: Vector2;
  16389. /** @hidden */
  16390. protected _isAnimationSheetEnabled: boolean;
  16391. /**
  16392. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16393. */
  16394. beginAnimationOnStart: boolean;
  16395. /**
  16396. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16397. */
  16398. beginAnimationFrom: number;
  16399. /**
  16400. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16401. */
  16402. beginAnimationTo: number;
  16403. /**
  16404. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16405. */
  16406. beginAnimationLoop: boolean;
  16407. /**
  16408. * Gets or sets a world offset applied to all particles
  16409. */
  16410. worldOffset: Vector3;
  16411. /**
  16412. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16413. */
  16414. isAnimationSheetEnabled: boolean;
  16415. /**
  16416. * Get hosting scene
  16417. * @returns the scene
  16418. */
  16419. getScene(): Scene;
  16420. /**
  16421. * You can use gravity if you want to give an orientation to your particles.
  16422. */
  16423. gravity: Vector3;
  16424. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16425. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16426. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16427. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16428. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16429. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16430. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16431. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16432. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16433. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16434. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16435. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16436. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16437. /**
  16438. * Defines the delay in milliseconds before starting the system (0 by default)
  16439. */
  16440. startDelay: number;
  16441. /**
  16442. * Gets the current list of drag gradients.
  16443. * You must use addDragGradient and removeDragGradient to udpate this list
  16444. * @returns the list of drag gradients
  16445. */
  16446. getDragGradients(): Nullable<Array<FactorGradient>>;
  16447. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16448. limitVelocityDamping: number;
  16449. /**
  16450. * Gets the current list of limit velocity gradients.
  16451. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16452. * @returns the list of limit velocity gradients
  16453. */
  16454. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16455. /**
  16456. * Gets the current list of color gradients.
  16457. * You must use addColorGradient and removeColorGradient to udpate this list
  16458. * @returns the list of color gradients
  16459. */
  16460. getColorGradients(): Nullable<Array<ColorGradient>>;
  16461. /**
  16462. * Gets the current list of size gradients.
  16463. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16464. * @returns the list of size gradients
  16465. */
  16466. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16467. /**
  16468. * Gets the current list of color remap gradients.
  16469. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16470. * @returns the list of color remap gradients
  16471. */
  16472. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16473. /**
  16474. * Gets the current list of alpha remap gradients.
  16475. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16476. * @returns the list of alpha remap gradients
  16477. */
  16478. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16479. /**
  16480. * Gets the current list of life time gradients.
  16481. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16482. * @returns the list of life time gradients
  16483. */
  16484. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16485. /**
  16486. * Gets the current list of angular speed gradients.
  16487. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16488. * @returns the list of angular speed gradients
  16489. */
  16490. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16491. /**
  16492. * Gets the current list of velocity gradients.
  16493. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16494. * @returns the list of velocity gradients
  16495. */
  16496. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16497. /**
  16498. * Gets the current list of start size gradients.
  16499. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16500. * @returns the list of start size gradients
  16501. */
  16502. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16503. /**
  16504. * Gets the current list of emit rate gradients.
  16505. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16506. * @returns the list of emit rate gradients
  16507. */
  16508. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16509. /**
  16510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16511. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16512. */
  16513. direction1: Vector3;
  16514. /**
  16515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16517. */
  16518. direction2: Vector3;
  16519. /**
  16520. * 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.
  16521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16522. */
  16523. minEmitBox: Vector3;
  16524. /**
  16525. * 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.
  16526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16527. */
  16528. maxEmitBox: Vector3;
  16529. /**
  16530. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16531. */
  16532. color1: Color4;
  16533. /**
  16534. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16535. */
  16536. color2: Color4;
  16537. /**
  16538. * Color the particle will have at the end of its lifetime
  16539. */
  16540. colorDead: Color4;
  16541. /**
  16542. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16543. */
  16544. textureMask: Color4;
  16545. /**
  16546. * The particle emitter type defines the emitter used by the particle system.
  16547. * It can be for example box, sphere, or cone...
  16548. */
  16549. particleEmitterType: IParticleEmitterType;
  16550. /** @hidden */
  16551. _isSubEmitter: boolean;
  16552. /**
  16553. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16554. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16555. */
  16556. billboardMode: number;
  16557. protected _isBillboardBased: boolean;
  16558. /**
  16559. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16560. */
  16561. isBillboardBased: boolean;
  16562. /**
  16563. * The scene the particle system belongs to.
  16564. */
  16565. protected _scene: Scene;
  16566. /**
  16567. * Local cache of defines for image processing.
  16568. */
  16569. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16570. /**
  16571. * Default configuration related to image processing available in the standard Material.
  16572. */
  16573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16574. /**
  16575. * Gets the image processing configuration used either in this material.
  16576. */
  16577. /**
  16578. * Sets the Default image processing configuration used either in the this material.
  16579. *
  16580. * If sets to null, the scene one is in use.
  16581. */
  16582. imageProcessingConfiguration: ImageProcessingConfiguration;
  16583. /**
  16584. * Attaches a new image processing configuration to the Standard Material.
  16585. * @param configuration
  16586. */
  16587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16588. /** @hidden */
  16589. protected _reset(): void;
  16590. /** @hidden */
  16591. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16592. /**
  16593. * Instantiates a particle system.
  16594. * 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.
  16595. * @param name The name of the particle system
  16596. */
  16597. constructor(name: string);
  16598. /**
  16599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16602. * @returns the emitter
  16603. */
  16604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16605. /**
  16606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16607. * @param radius The radius of the hemisphere to emit from
  16608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16609. * @returns the emitter
  16610. */
  16611. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16612. /**
  16613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16614. * @param radius The radius of the sphere to emit from
  16615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16616. * @returns the emitter
  16617. */
  16618. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16619. /**
  16620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16621. * @param radius The radius of the sphere to emit from
  16622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16624. * @returns the emitter
  16625. */
  16626. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16627. /**
  16628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16629. * @param radius The radius of the emission cylinder
  16630. * @param height The height of the emission cylinder
  16631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16633. * @returns the emitter
  16634. */
  16635. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16636. /**
  16637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16638. * @param radius The radius of the cylinder to emit from
  16639. * @param height The height of the emission cylinder
  16640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16643. * @returns the emitter
  16644. */
  16645. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16646. /**
  16647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16648. * @param radius The radius of the cone to emit from
  16649. * @param angle The base angle of the cone
  16650. * @returns the emitter
  16651. */
  16652. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16653. /**
  16654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16659. * @returns the emitter
  16660. */
  16661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16662. }
  16663. }
  16664. declare module BABYLON {
  16665. /**
  16666. * Type of sub emitter
  16667. */
  16668. export enum SubEmitterType {
  16669. /**
  16670. * Attached to the particle over it's lifetime
  16671. */
  16672. ATTACHED = 0,
  16673. /**
  16674. * Created when the particle dies
  16675. */
  16676. END = 1
  16677. }
  16678. /**
  16679. * Sub emitter class used to emit particles from an existing particle
  16680. */
  16681. export class SubEmitter {
  16682. /**
  16683. * the particle system to be used by the sub emitter
  16684. */
  16685. particleSystem: ParticleSystem;
  16686. /**
  16687. * Type of the submitter (Default: END)
  16688. */
  16689. type: SubEmitterType;
  16690. /**
  16691. * 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)
  16692. * Note: This only is supported when using an emitter of type Mesh
  16693. */
  16694. inheritDirection: boolean;
  16695. /**
  16696. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16697. */
  16698. inheritedVelocityAmount: number;
  16699. /**
  16700. * Creates a sub emitter
  16701. * @param particleSystem the particle system to be used by the sub emitter
  16702. */
  16703. constructor(
  16704. /**
  16705. * the particle system to be used by the sub emitter
  16706. */
  16707. particleSystem: ParticleSystem);
  16708. /**
  16709. * Clones the sub emitter
  16710. * @returns the cloned sub emitter
  16711. */
  16712. clone(): SubEmitter;
  16713. /**
  16714. * Serialize current object to a JSON object
  16715. * @returns the serialized object
  16716. */
  16717. serialize(): any;
  16718. /** @hidden */
  16719. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16720. /**
  16721. * Creates a new SubEmitter from a serialized JSON version
  16722. * @param serializationObject defines the JSON object to read from
  16723. * @param scene defines the hosting scene
  16724. * @param rootUrl defines the rootUrl for data loading
  16725. * @returns a new SubEmitter
  16726. */
  16727. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16728. /** Release associated resources */
  16729. dispose(): void;
  16730. }
  16731. }
  16732. declare module BABYLON {
  16733. /** @hidden */
  16734. export var clipPlaneFragmentDeclaration: {
  16735. name: string;
  16736. shader: string;
  16737. };
  16738. }
  16739. declare module BABYLON {
  16740. /** @hidden */
  16741. export var imageProcessingDeclaration: {
  16742. name: string;
  16743. shader: string;
  16744. };
  16745. }
  16746. declare module BABYLON {
  16747. /** @hidden */
  16748. export var imageProcessingFunctions: {
  16749. name: string;
  16750. shader: string;
  16751. };
  16752. }
  16753. declare module BABYLON {
  16754. /** @hidden */
  16755. export var clipPlaneFragment: {
  16756. name: string;
  16757. shader: string;
  16758. };
  16759. }
  16760. declare module BABYLON {
  16761. /** @hidden */
  16762. export var particlesPixelShader: {
  16763. name: string;
  16764. shader: string;
  16765. };
  16766. }
  16767. declare module BABYLON {
  16768. /** @hidden */
  16769. export var clipPlaneVertexDeclaration: {
  16770. name: string;
  16771. shader: string;
  16772. };
  16773. }
  16774. declare module BABYLON {
  16775. /** @hidden */
  16776. export var clipPlaneVertex: {
  16777. name: string;
  16778. shader: string;
  16779. };
  16780. }
  16781. declare module BABYLON {
  16782. /** @hidden */
  16783. export var particlesVertexShader: {
  16784. name: string;
  16785. shader: string;
  16786. };
  16787. }
  16788. declare module BABYLON {
  16789. /**
  16790. * This represents a particle system in Babylon.
  16791. * 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.
  16792. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16793. * @example https://doc.babylonjs.com/babylon101/particles
  16794. */
  16795. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16796. /**
  16797. * Billboard mode will only apply to Y axis
  16798. */
  16799. static readonly BILLBOARDMODE_Y: number;
  16800. /**
  16801. * Billboard mode will apply to all axes
  16802. */
  16803. static readonly BILLBOARDMODE_ALL: number;
  16804. /**
  16805. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16806. */
  16807. static readonly BILLBOARDMODE_STRETCHED: number;
  16808. /**
  16809. * This function can be defined to provide custom update for active particles.
  16810. * This function will be called instead of regular update (age, position, color, etc.).
  16811. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16812. */
  16813. updateFunction: (particles: Particle[]) => void;
  16814. private _emitterWorldMatrix;
  16815. /**
  16816. * This function can be defined to specify initial direction for every new particle.
  16817. * It by default use the emitterType defined function
  16818. */
  16819. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16820. /**
  16821. * This function can be defined to specify initial position for every new particle.
  16822. * It by default use the emitterType defined function
  16823. */
  16824. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16825. /**
  16826. * @hidden
  16827. */
  16828. _inheritedVelocityOffset: Vector3;
  16829. /**
  16830. * An event triggered when the system is disposed
  16831. */
  16832. onDisposeObservable: Observable<ParticleSystem>;
  16833. private _onDisposeObserver;
  16834. /**
  16835. * Sets a callback that will be triggered when the system is disposed
  16836. */
  16837. onDispose: () => void;
  16838. private _particles;
  16839. private _epsilon;
  16840. private _capacity;
  16841. private _stockParticles;
  16842. private _newPartsExcess;
  16843. private _vertexData;
  16844. private _vertexBuffer;
  16845. private _vertexBuffers;
  16846. private _spriteBuffer;
  16847. private _indexBuffer;
  16848. private _effect;
  16849. private _customEffect;
  16850. private _cachedDefines;
  16851. private _scaledColorStep;
  16852. private _colorDiff;
  16853. private _scaledDirection;
  16854. private _scaledGravity;
  16855. private _currentRenderId;
  16856. private _alive;
  16857. private _useInstancing;
  16858. private _started;
  16859. private _stopped;
  16860. private _actualFrame;
  16861. private _scaledUpdateSpeed;
  16862. private _vertexBufferSize;
  16863. /** @hidden */
  16864. _currentEmitRateGradient: Nullable<FactorGradient>;
  16865. /** @hidden */
  16866. _currentEmitRate1: number;
  16867. /** @hidden */
  16868. _currentEmitRate2: number;
  16869. /** @hidden */
  16870. _currentStartSizeGradient: Nullable<FactorGradient>;
  16871. /** @hidden */
  16872. _currentStartSize1: number;
  16873. /** @hidden */
  16874. _currentStartSize2: number;
  16875. private readonly _rawTextureWidth;
  16876. private _rampGradientsTexture;
  16877. private _useRampGradients;
  16878. /** Gets or sets a boolean indicating that ramp gradients must be used
  16879. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16880. */
  16881. useRampGradients: boolean;
  16882. /**
  16883. * 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.
  16884. * 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: [])
  16885. */
  16886. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16887. private _subEmitters;
  16888. /**
  16889. * @hidden
  16890. * If the particle systems emitter should be disposed when the particle system is disposed
  16891. */
  16892. _disposeEmitterOnDispose: boolean;
  16893. /**
  16894. * The current active Sub-systems, this property is used by the root particle system only.
  16895. */
  16896. activeSubSystems: Array<ParticleSystem>;
  16897. private _rootParticleSystem;
  16898. /**
  16899. * Gets the current list of active particles
  16900. */
  16901. readonly particles: Particle[];
  16902. /**
  16903. * Returns the string "ParticleSystem"
  16904. * @returns a string containing the class name
  16905. */
  16906. getClassName(): string;
  16907. /**
  16908. * Instantiates a particle system.
  16909. * 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.
  16910. * @param name The name of the particle system
  16911. * @param capacity The max number of particles alive at the same time
  16912. * @param scene The scene the particle system belongs to
  16913. * @param customEffect a custom effect used to change the way particles are rendered by default
  16914. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16915. * @param epsilon Offset used to render the particles
  16916. */
  16917. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16918. private _addFactorGradient;
  16919. private _removeFactorGradient;
  16920. /**
  16921. * Adds a new life time gradient
  16922. * @param gradient defines the gradient to use (between 0 and 1)
  16923. * @param factor defines the life time factor to affect to the specified gradient
  16924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16925. * @returns the current particle system
  16926. */
  16927. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16928. /**
  16929. * Remove a specific life time gradient
  16930. * @param gradient defines the gradient to remove
  16931. * @returns the current particle system
  16932. */
  16933. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16934. /**
  16935. * Adds a new size gradient
  16936. * @param gradient defines the gradient to use (between 0 and 1)
  16937. * @param factor defines the size factor to affect to the specified gradient
  16938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16939. * @returns the current particle system
  16940. */
  16941. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16942. /**
  16943. * Remove a specific size gradient
  16944. * @param gradient defines the gradient to remove
  16945. * @returns the current particle system
  16946. */
  16947. removeSizeGradient(gradient: number): IParticleSystem;
  16948. /**
  16949. * Adds a new color remap gradient
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param min defines the color remap minimal range
  16952. * @param max defines the color remap maximal range
  16953. * @returns the current particle system
  16954. */
  16955. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16956. /**
  16957. * Remove a specific color remap gradient
  16958. * @param gradient defines the gradient to remove
  16959. * @returns the current particle system
  16960. */
  16961. removeColorRemapGradient(gradient: number): IParticleSystem;
  16962. /**
  16963. * Adds a new alpha remap gradient
  16964. * @param gradient defines the gradient to use (between 0 and 1)
  16965. * @param min defines the alpha remap minimal range
  16966. * @param max defines the alpha remap maximal range
  16967. * @returns the current particle system
  16968. */
  16969. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16970. /**
  16971. * Remove a specific alpha remap gradient
  16972. * @param gradient defines the gradient to remove
  16973. * @returns the current particle system
  16974. */
  16975. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16976. /**
  16977. * Adds a new angular speed gradient
  16978. * @param gradient defines the gradient to use (between 0 and 1)
  16979. * @param factor defines the angular speed to affect to the specified gradient
  16980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16981. * @returns the current particle system
  16982. */
  16983. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16984. /**
  16985. * Remove a specific angular speed gradient
  16986. * @param gradient defines the gradient to remove
  16987. * @returns the current particle system
  16988. */
  16989. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16990. /**
  16991. * Adds a new velocity gradient
  16992. * @param gradient defines the gradient to use (between 0 and 1)
  16993. * @param factor defines the velocity to affect to the specified gradient
  16994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16995. * @returns the current particle system
  16996. */
  16997. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16998. /**
  16999. * Remove a specific velocity gradient
  17000. * @param gradient defines the gradient to remove
  17001. * @returns the current particle system
  17002. */
  17003. removeVelocityGradient(gradient: number): IParticleSystem;
  17004. /**
  17005. * Adds a new limit velocity gradient
  17006. * @param gradient defines the gradient to use (between 0 and 1)
  17007. * @param factor defines the limit velocity value to affect to the specified gradient
  17008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17009. * @returns the current particle system
  17010. */
  17011. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17012. /**
  17013. * Remove a specific limit velocity gradient
  17014. * @param gradient defines the gradient to remove
  17015. * @returns the current particle system
  17016. */
  17017. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17018. /**
  17019. * Adds a new drag gradient
  17020. * @param gradient defines the gradient to use (between 0 and 1)
  17021. * @param factor defines the drag value to affect to the specified gradient
  17022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17023. * @returns the current particle system
  17024. */
  17025. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17026. /**
  17027. * Remove a specific drag gradient
  17028. * @param gradient defines the gradient to remove
  17029. * @returns the current particle system
  17030. */
  17031. removeDragGradient(gradient: number): IParticleSystem;
  17032. /**
  17033. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17034. * @param gradient defines the gradient to use (between 0 and 1)
  17035. * @param factor defines the emit rate value to affect to the specified gradient
  17036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17037. * @returns the current particle system
  17038. */
  17039. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17040. /**
  17041. * Remove a specific emit rate gradient
  17042. * @param gradient defines the gradient to remove
  17043. * @returns the current particle system
  17044. */
  17045. removeEmitRateGradient(gradient: number): IParticleSystem;
  17046. /**
  17047. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17048. * @param gradient defines the gradient to use (between 0 and 1)
  17049. * @param factor defines the start size value to affect to the specified gradient
  17050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17051. * @returns the current particle system
  17052. */
  17053. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17054. /**
  17055. * Remove a specific start size gradient
  17056. * @param gradient defines the gradient to remove
  17057. * @returns the current particle system
  17058. */
  17059. removeStartSizeGradient(gradient: number): IParticleSystem;
  17060. private _createRampGradientTexture;
  17061. /**
  17062. * Gets the current list of ramp gradients.
  17063. * You must use addRampGradient and removeRampGradient to udpate this list
  17064. * @returns the list of ramp gradients
  17065. */
  17066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17067. /**
  17068. * Adds a new ramp gradient used to remap particle colors
  17069. * @param gradient defines the gradient to use (between 0 and 1)
  17070. * @param color defines the color to affect to the specified gradient
  17071. * @returns the current particle system
  17072. */
  17073. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17074. /**
  17075. * Remove a specific ramp gradient
  17076. * @param gradient defines the gradient to remove
  17077. * @returns the current particle system
  17078. */
  17079. removeRampGradient(gradient: number): ParticleSystem;
  17080. /**
  17081. * Adds a new color gradient
  17082. * @param gradient defines the gradient to use (between 0 and 1)
  17083. * @param color1 defines the color to affect to the specified gradient
  17084. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17085. * @returns this particle system
  17086. */
  17087. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17088. /**
  17089. * Remove a specific color gradient
  17090. * @param gradient defines the gradient to remove
  17091. * @returns this particle system
  17092. */
  17093. removeColorGradient(gradient: number): IParticleSystem;
  17094. private _fetchR;
  17095. protected _reset(): void;
  17096. private _resetEffect;
  17097. private _createVertexBuffers;
  17098. private _createIndexBuffer;
  17099. /**
  17100. * Gets the maximum number of particles active at the same time.
  17101. * @returns The max number of active particles.
  17102. */
  17103. getCapacity(): number;
  17104. /**
  17105. * Gets whether there are still active particles in the system.
  17106. * @returns True if it is alive, otherwise false.
  17107. */
  17108. isAlive(): boolean;
  17109. /**
  17110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17111. * @returns True if it has been started, otherwise false.
  17112. */
  17113. isStarted(): boolean;
  17114. private _prepareSubEmitterInternalArray;
  17115. /**
  17116. * Starts the particle system and begins to emit
  17117. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17118. */
  17119. start(delay?: number): void;
  17120. /**
  17121. * Stops the particle system.
  17122. * @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.
  17123. */
  17124. stop(stopSubEmitters?: boolean): void;
  17125. /**
  17126. * Remove all active particles
  17127. */
  17128. reset(): void;
  17129. /**
  17130. * @hidden (for internal use only)
  17131. */
  17132. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17133. /**
  17134. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17135. * Its lifetime will start back at 0.
  17136. */
  17137. recycleParticle: (particle: Particle) => void;
  17138. private _stopSubEmitters;
  17139. private _createParticle;
  17140. private _removeFromRoot;
  17141. private _emitFromParticle;
  17142. private _update;
  17143. /** @hidden */
  17144. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17145. /** @hidden */
  17146. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17147. /** @hidden */
  17148. private _getEffect;
  17149. /**
  17150. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17151. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17152. */
  17153. animate(preWarmOnly?: boolean): void;
  17154. private _appendParticleVertices;
  17155. /**
  17156. * Rebuilds the particle system.
  17157. */
  17158. rebuild(): void;
  17159. /**
  17160. * Is this system ready to be used/rendered
  17161. * @return true if the system is ready
  17162. */
  17163. isReady(): boolean;
  17164. private _render;
  17165. /**
  17166. * Renders the particle system in its current state.
  17167. * @returns the current number of particles
  17168. */
  17169. render(): number;
  17170. /**
  17171. * Disposes the particle system and free the associated resources
  17172. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17173. */
  17174. dispose(disposeTexture?: boolean): void;
  17175. /**
  17176. * Clones the particle system.
  17177. * @param name The name of the cloned object
  17178. * @param newEmitter The new emitter to use
  17179. * @returns the cloned particle system
  17180. */
  17181. clone(name: string, newEmitter: any): ParticleSystem;
  17182. /**
  17183. * Serializes the particle system to a JSON object.
  17184. * @returns the JSON object
  17185. */
  17186. serialize(): any;
  17187. /** @hidden */
  17188. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17189. /** @hidden */
  17190. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17191. /**
  17192. * Parses a JSON object to create a particle system.
  17193. * @param parsedParticleSystem The JSON object to parse
  17194. * @param scene The scene to create the particle system in
  17195. * @param rootUrl The root url to use to load external dependencies like texture
  17196. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17197. * @returns the Parsed particle system
  17198. */
  17199. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17200. }
  17201. }
  17202. declare module BABYLON {
  17203. /**
  17204. * A particle represents one of the element emitted by a particle system.
  17205. * This is mainly define by its coordinates, direction, velocity and age.
  17206. */
  17207. export class Particle {
  17208. /**
  17209. * The particle system the particle belongs to.
  17210. */
  17211. particleSystem: ParticleSystem;
  17212. private static _Count;
  17213. /**
  17214. * Unique ID of the particle
  17215. */
  17216. id: number;
  17217. /**
  17218. * The world position of the particle in the scene.
  17219. */
  17220. position: Vector3;
  17221. /**
  17222. * The world direction of the particle in the scene.
  17223. */
  17224. direction: Vector3;
  17225. /**
  17226. * The color of the particle.
  17227. */
  17228. color: Color4;
  17229. /**
  17230. * The color change of the particle per step.
  17231. */
  17232. colorStep: Color4;
  17233. /**
  17234. * Defines how long will the life of the particle be.
  17235. */
  17236. lifeTime: number;
  17237. /**
  17238. * The current age of the particle.
  17239. */
  17240. age: number;
  17241. /**
  17242. * The current size of the particle.
  17243. */
  17244. size: number;
  17245. /**
  17246. * The current scale of the particle.
  17247. */
  17248. scale: Vector2;
  17249. /**
  17250. * The current angle of the particle.
  17251. */
  17252. angle: number;
  17253. /**
  17254. * Defines how fast is the angle changing.
  17255. */
  17256. angularSpeed: number;
  17257. /**
  17258. * Defines the cell index used by the particle to be rendered from a sprite.
  17259. */
  17260. cellIndex: number;
  17261. /**
  17262. * The information required to support color remapping
  17263. */
  17264. remapData: Vector4;
  17265. /** @hidden */
  17266. _randomCellOffset?: number;
  17267. /** @hidden */
  17268. _initialDirection: Nullable<Vector3>;
  17269. /** @hidden */
  17270. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17271. /** @hidden */
  17272. _initialStartSpriteCellID: number;
  17273. /** @hidden */
  17274. _initialEndSpriteCellID: number;
  17275. /** @hidden */
  17276. _currentColorGradient: Nullable<ColorGradient>;
  17277. /** @hidden */
  17278. _currentColor1: Color4;
  17279. /** @hidden */
  17280. _currentColor2: Color4;
  17281. /** @hidden */
  17282. _currentSizeGradient: Nullable<FactorGradient>;
  17283. /** @hidden */
  17284. _currentSize1: number;
  17285. /** @hidden */
  17286. _currentSize2: number;
  17287. /** @hidden */
  17288. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17289. /** @hidden */
  17290. _currentAngularSpeed1: number;
  17291. /** @hidden */
  17292. _currentAngularSpeed2: number;
  17293. /** @hidden */
  17294. _currentVelocityGradient: Nullable<FactorGradient>;
  17295. /** @hidden */
  17296. _currentVelocity1: number;
  17297. /** @hidden */
  17298. _currentVelocity2: number;
  17299. /** @hidden */
  17300. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17301. /** @hidden */
  17302. _currentLimitVelocity1: number;
  17303. /** @hidden */
  17304. _currentLimitVelocity2: number;
  17305. /** @hidden */
  17306. _currentDragGradient: Nullable<FactorGradient>;
  17307. /** @hidden */
  17308. _currentDrag1: number;
  17309. /** @hidden */
  17310. _currentDrag2: number;
  17311. /** @hidden */
  17312. _randomNoiseCoordinates1: Vector3;
  17313. /** @hidden */
  17314. _randomNoiseCoordinates2: Vector3;
  17315. /**
  17316. * Creates a new instance Particle
  17317. * @param particleSystem the particle system the particle belongs to
  17318. */
  17319. constructor(
  17320. /**
  17321. * The particle system the particle belongs to.
  17322. */
  17323. particleSystem: ParticleSystem);
  17324. private updateCellInfoFromSystem;
  17325. /**
  17326. * Defines how the sprite cell index is updated for the particle
  17327. */
  17328. updateCellIndex(): void;
  17329. /** @hidden */
  17330. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17331. /** @hidden */
  17332. _inheritParticleInfoToSubEmitters(): void;
  17333. /** @hidden */
  17334. _reset(): void;
  17335. /**
  17336. * Copy the properties of particle to another one.
  17337. * @param other the particle to copy the information to.
  17338. */
  17339. copyTo(other: Particle): void;
  17340. }
  17341. }
  17342. declare module BABYLON {
  17343. /**
  17344. * Particle emitter represents a volume emitting particles.
  17345. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17346. */
  17347. export interface IParticleEmitterType {
  17348. /**
  17349. * Called by the particle System when the direction is computed for the created particle.
  17350. * @param worldMatrix is the world matrix of the particle system
  17351. * @param directionToUpdate is the direction vector to update with the result
  17352. * @param particle is the particle we are computed the direction for
  17353. */
  17354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17355. /**
  17356. * Called by the particle System when the position is computed for the created particle.
  17357. * @param worldMatrix is the world matrix of the particle system
  17358. * @param positionToUpdate is the position vector to update with the result
  17359. * @param particle is the particle we are computed the position for
  17360. */
  17361. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17362. /**
  17363. * Clones the current emitter and returns a copy of it
  17364. * @returns the new emitter
  17365. */
  17366. clone(): IParticleEmitterType;
  17367. /**
  17368. * Called by the GPUParticleSystem to setup the update shader
  17369. * @param effect defines the update shader
  17370. */
  17371. applyToShader(effect: Effect): void;
  17372. /**
  17373. * Returns a string to use to update the GPU particles update shader
  17374. * @returns the effect defines string
  17375. */
  17376. getEffectDefines(): string;
  17377. /**
  17378. * Returns a string representing the class name
  17379. * @returns a string containing the class name
  17380. */
  17381. getClassName(): string;
  17382. /**
  17383. * Serializes the particle system to a JSON object.
  17384. * @returns the JSON object
  17385. */
  17386. serialize(): any;
  17387. /**
  17388. * Parse properties from a JSON object
  17389. * @param serializationObject defines the JSON object
  17390. */
  17391. parse(serializationObject: any): void;
  17392. }
  17393. }
  17394. declare module BABYLON {
  17395. /**
  17396. * Particle emitter emitting particles from the inside of a box.
  17397. * It emits the particles randomly between 2 given directions.
  17398. */
  17399. export class BoxParticleEmitter implements IParticleEmitterType {
  17400. /**
  17401. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17402. */
  17403. direction1: Vector3;
  17404. /**
  17405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17406. */
  17407. direction2: Vector3;
  17408. /**
  17409. * 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.
  17410. */
  17411. minEmitBox: Vector3;
  17412. /**
  17413. * 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.
  17414. */
  17415. maxEmitBox: Vector3;
  17416. /**
  17417. * Creates a new instance BoxParticleEmitter
  17418. */
  17419. constructor();
  17420. /**
  17421. * Called by the particle System when the direction is computed for the created particle.
  17422. * @param worldMatrix is the world matrix of the particle system
  17423. * @param directionToUpdate is the direction vector to update with the result
  17424. * @param particle is the particle we are computed the direction for
  17425. */
  17426. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17427. /**
  17428. * Called by the particle System when the position is computed for the created particle.
  17429. * @param worldMatrix is the world matrix of the particle system
  17430. * @param positionToUpdate is the position vector to update with the result
  17431. * @param particle is the particle we are computed the position for
  17432. */
  17433. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17434. /**
  17435. * Clones the current emitter and returns a copy of it
  17436. * @returns the new emitter
  17437. */
  17438. clone(): BoxParticleEmitter;
  17439. /**
  17440. * Called by the GPUParticleSystem to setup the update shader
  17441. * @param effect defines the update shader
  17442. */
  17443. applyToShader(effect: Effect): void;
  17444. /**
  17445. * Returns a string to use to update the GPU particles update shader
  17446. * @returns a string containng the defines string
  17447. */
  17448. getEffectDefines(): string;
  17449. /**
  17450. * Returns the string "BoxParticleEmitter"
  17451. * @returns a string containing the class name
  17452. */
  17453. getClassName(): string;
  17454. /**
  17455. * Serializes the particle system to a JSON object.
  17456. * @returns the JSON object
  17457. */
  17458. serialize(): any;
  17459. /**
  17460. * Parse properties from a JSON object
  17461. * @param serializationObject defines the JSON object
  17462. */
  17463. parse(serializationObject: any): void;
  17464. }
  17465. }
  17466. declare module BABYLON {
  17467. /**
  17468. * Particle emitter emitting particles from the inside of a cone.
  17469. * It emits the particles alongside the cone volume from the base to the particle.
  17470. * The emission direction might be randomized.
  17471. */
  17472. export class ConeParticleEmitter implements IParticleEmitterType {
  17473. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17474. directionRandomizer: number;
  17475. private _radius;
  17476. private _angle;
  17477. private _height;
  17478. /**
  17479. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17480. */
  17481. radiusRange: number;
  17482. /**
  17483. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17484. */
  17485. heightRange: number;
  17486. /**
  17487. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17488. */
  17489. emitFromSpawnPointOnly: boolean;
  17490. /**
  17491. * Gets or sets the radius of the emission cone
  17492. */
  17493. radius: number;
  17494. /**
  17495. * Gets or sets the angle of the emission cone
  17496. */
  17497. angle: number;
  17498. private _buildHeight;
  17499. /**
  17500. * Creates a new instance ConeParticleEmitter
  17501. * @param radius the radius of the emission cone (1 by default)
  17502. * @param angle the cone base angle (PI by default)
  17503. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17504. */
  17505. constructor(radius?: number, angle?: number,
  17506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17507. directionRandomizer?: number);
  17508. /**
  17509. * Called by the particle System when the direction is computed for the created particle.
  17510. * @param worldMatrix is the world matrix of the particle system
  17511. * @param directionToUpdate is the direction vector to update with the result
  17512. * @param particle is the particle we are computed the direction for
  17513. */
  17514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17515. /**
  17516. * Called by the particle System when the position is computed for the created particle.
  17517. * @param worldMatrix is the world matrix of the particle system
  17518. * @param positionToUpdate is the position vector to update with the result
  17519. * @param particle is the particle we are computed the position for
  17520. */
  17521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17522. /**
  17523. * Clones the current emitter and returns a copy of it
  17524. * @returns the new emitter
  17525. */
  17526. clone(): ConeParticleEmitter;
  17527. /**
  17528. * Called by the GPUParticleSystem to setup the update shader
  17529. * @param effect defines the update shader
  17530. */
  17531. applyToShader(effect: Effect): void;
  17532. /**
  17533. * Returns a string to use to update the GPU particles update shader
  17534. * @returns a string containng the defines string
  17535. */
  17536. getEffectDefines(): string;
  17537. /**
  17538. * Returns the string "ConeParticleEmitter"
  17539. * @returns a string containing the class name
  17540. */
  17541. getClassName(): string;
  17542. /**
  17543. * Serializes the particle system to a JSON object.
  17544. * @returns the JSON object
  17545. */
  17546. serialize(): any;
  17547. /**
  17548. * Parse properties from a JSON object
  17549. * @param serializationObject defines the JSON object
  17550. */
  17551. parse(serializationObject: any): void;
  17552. }
  17553. }
  17554. declare module BABYLON {
  17555. /**
  17556. * Particle emitter emitting particles from the inside of a cylinder.
  17557. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17558. */
  17559. export class CylinderParticleEmitter implements IParticleEmitterType {
  17560. /**
  17561. * The radius of the emission cylinder.
  17562. */
  17563. radius: number;
  17564. /**
  17565. * The height of the emission cylinder.
  17566. */
  17567. height: number;
  17568. /**
  17569. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17570. */
  17571. radiusRange: number;
  17572. /**
  17573. * How much to randomize the particle direction [0-1].
  17574. */
  17575. directionRandomizer: number;
  17576. /**
  17577. * Creates a new instance CylinderParticleEmitter
  17578. * @param radius the radius of the emission cylinder (1 by default)
  17579. * @param height the height of the emission cylinder (1 by default)
  17580. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17582. */
  17583. constructor(
  17584. /**
  17585. * The radius of the emission cylinder.
  17586. */
  17587. radius?: number,
  17588. /**
  17589. * The height of the emission cylinder.
  17590. */
  17591. height?: number,
  17592. /**
  17593. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17594. */
  17595. radiusRange?: number,
  17596. /**
  17597. * How much to randomize the particle direction [0-1].
  17598. */
  17599. directionRandomizer?: number);
  17600. /**
  17601. * Called by the particle System when the direction is computed for the created particle.
  17602. * @param worldMatrix is the world matrix of the particle system
  17603. * @param directionToUpdate is the direction vector to update with the result
  17604. * @param particle is the particle we are computed the direction for
  17605. */
  17606. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17607. /**
  17608. * Called by the particle System when the position is computed for the created particle.
  17609. * @param worldMatrix is the world matrix of the particle system
  17610. * @param positionToUpdate is the position vector to update with the result
  17611. * @param particle is the particle we are computed the position for
  17612. */
  17613. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17614. /**
  17615. * Clones the current emitter and returns a copy of it
  17616. * @returns the new emitter
  17617. */
  17618. clone(): CylinderParticleEmitter;
  17619. /**
  17620. * Called by the GPUParticleSystem to setup the update shader
  17621. * @param effect defines the update shader
  17622. */
  17623. applyToShader(effect: Effect): void;
  17624. /**
  17625. * Returns a string to use to update the GPU particles update shader
  17626. * @returns a string containng the defines string
  17627. */
  17628. getEffectDefines(): string;
  17629. /**
  17630. * Returns the string "CylinderParticleEmitter"
  17631. * @returns a string containing the class name
  17632. */
  17633. getClassName(): string;
  17634. /**
  17635. * Serializes the particle system to a JSON object.
  17636. * @returns the JSON object
  17637. */
  17638. serialize(): any;
  17639. /**
  17640. * Parse properties from a JSON object
  17641. * @param serializationObject defines the JSON object
  17642. */
  17643. parse(serializationObject: any): void;
  17644. }
  17645. /**
  17646. * Particle emitter emitting particles from the inside of a cylinder.
  17647. * It emits the particles randomly between two vectors.
  17648. */
  17649. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17650. /**
  17651. * The min limit of the emission direction.
  17652. */
  17653. direction1: Vector3;
  17654. /**
  17655. * The max limit of the emission direction.
  17656. */
  17657. direction2: Vector3;
  17658. /**
  17659. * Creates a new instance CylinderDirectedParticleEmitter
  17660. * @param radius the radius of the emission cylinder (1 by default)
  17661. * @param height the height of the emission cylinder (1 by default)
  17662. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17663. * @param direction1 the min limit of the emission direction (up vector by default)
  17664. * @param direction2 the max limit of the emission direction (up vector by default)
  17665. */
  17666. constructor(radius?: number, height?: number, radiusRange?: number,
  17667. /**
  17668. * The min limit of the emission direction.
  17669. */
  17670. direction1?: Vector3,
  17671. /**
  17672. * The max limit of the emission direction.
  17673. */
  17674. direction2?: Vector3);
  17675. /**
  17676. * Called by the particle System when the direction is computed for the created particle.
  17677. * @param worldMatrix is the world matrix of the particle system
  17678. * @param directionToUpdate is the direction vector to update with the result
  17679. * @param particle is the particle we are computed the direction for
  17680. */
  17681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17682. /**
  17683. * Clones the current emitter and returns a copy of it
  17684. * @returns the new emitter
  17685. */
  17686. clone(): CylinderDirectedParticleEmitter;
  17687. /**
  17688. * Called by the GPUParticleSystem to setup the update shader
  17689. * @param effect defines the update shader
  17690. */
  17691. applyToShader(effect: Effect): void;
  17692. /**
  17693. * Returns a string to use to update the GPU particles update shader
  17694. * @returns a string containng the defines string
  17695. */
  17696. getEffectDefines(): string;
  17697. /**
  17698. * Returns the string "CylinderDirectedParticleEmitter"
  17699. * @returns a string containing the class name
  17700. */
  17701. getClassName(): string;
  17702. /**
  17703. * Serializes the particle system to a JSON object.
  17704. * @returns the JSON object
  17705. */
  17706. serialize(): any;
  17707. /**
  17708. * Parse properties from a JSON object
  17709. * @param serializationObject defines the JSON object
  17710. */
  17711. parse(serializationObject: any): void;
  17712. }
  17713. }
  17714. declare module BABYLON {
  17715. /**
  17716. * Particle emitter emitting particles from the inside of a hemisphere.
  17717. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17718. */
  17719. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17720. /**
  17721. * The radius of the emission hemisphere.
  17722. */
  17723. radius: number;
  17724. /**
  17725. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17726. */
  17727. radiusRange: number;
  17728. /**
  17729. * How much to randomize the particle direction [0-1].
  17730. */
  17731. directionRandomizer: number;
  17732. /**
  17733. * Creates a new instance HemisphericParticleEmitter
  17734. * @param radius the radius of the emission hemisphere (1 by default)
  17735. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17736. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17737. */
  17738. constructor(
  17739. /**
  17740. * The radius of the emission hemisphere.
  17741. */
  17742. radius?: number,
  17743. /**
  17744. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17745. */
  17746. radiusRange?: number,
  17747. /**
  17748. * How much to randomize the particle direction [0-1].
  17749. */
  17750. directionRandomizer?: number);
  17751. /**
  17752. * Called by the particle System when the direction is computed for the created particle.
  17753. * @param worldMatrix is the world matrix of the particle system
  17754. * @param directionToUpdate is the direction vector to update with the result
  17755. * @param particle is the particle we are computed the direction for
  17756. */
  17757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17758. /**
  17759. * Called by the particle System when the position is computed for the created particle.
  17760. * @param worldMatrix is the world matrix of the particle system
  17761. * @param positionToUpdate is the position vector to update with the result
  17762. * @param particle is the particle we are computed the position for
  17763. */
  17764. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17765. /**
  17766. * Clones the current emitter and returns a copy of it
  17767. * @returns the new emitter
  17768. */
  17769. clone(): HemisphericParticleEmitter;
  17770. /**
  17771. * Called by the GPUParticleSystem to setup the update shader
  17772. * @param effect defines the update shader
  17773. */
  17774. applyToShader(effect: Effect): void;
  17775. /**
  17776. * Returns a string to use to update the GPU particles update shader
  17777. * @returns a string containng the defines string
  17778. */
  17779. getEffectDefines(): string;
  17780. /**
  17781. * Returns the string "HemisphericParticleEmitter"
  17782. * @returns a string containing the class name
  17783. */
  17784. getClassName(): string;
  17785. /**
  17786. * Serializes the particle system to a JSON object.
  17787. * @returns the JSON object
  17788. */
  17789. serialize(): any;
  17790. /**
  17791. * Parse properties from a JSON object
  17792. * @param serializationObject defines the JSON object
  17793. */
  17794. parse(serializationObject: any): void;
  17795. }
  17796. }
  17797. declare module BABYLON {
  17798. /**
  17799. * Particle emitter emitting particles from a point.
  17800. * It emits the particles randomly between 2 given directions.
  17801. */
  17802. export class PointParticleEmitter implements IParticleEmitterType {
  17803. /**
  17804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17805. */
  17806. direction1: Vector3;
  17807. /**
  17808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17809. */
  17810. direction2: Vector3;
  17811. /**
  17812. * Creates a new instance PointParticleEmitter
  17813. */
  17814. constructor();
  17815. /**
  17816. * Called by the particle System when the direction is computed for the created particle.
  17817. * @param worldMatrix is the world matrix of the particle system
  17818. * @param directionToUpdate is the direction vector to update with the result
  17819. * @param particle is the particle we are computed the direction for
  17820. */
  17821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17822. /**
  17823. * Called by the particle System when the position is computed for the created particle.
  17824. * @param worldMatrix is the world matrix of the particle system
  17825. * @param positionToUpdate is the position vector to update with the result
  17826. * @param particle is the particle we are computed the position for
  17827. */
  17828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17829. /**
  17830. * Clones the current emitter and returns a copy of it
  17831. * @returns the new emitter
  17832. */
  17833. clone(): PointParticleEmitter;
  17834. /**
  17835. * Called by the GPUParticleSystem to setup the update shader
  17836. * @param effect defines the update shader
  17837. */
  17838. applyToShader(effect: Effect): void;
  17839. /**
  17840. * Returns a string to use to update the GPU particles update shader
  17841. * @returns a string containng the defines string
  17842. */
  17843. getEffectDefines(): string;
  17844. /**
  17845. * Returns the string "PointParticleEmitter"
  17846. * @returns a string containing the class name
  17847. */
  17848. getClassName(): string;
  17849. /**
  17850. * Serializes the particle system to a JSON object.
  17851. * @returns the JSON object
  17852. */
  17853. serialize(): any;
  17854. /**
  17855. * Parse properties from a JSON object
  17856. * @param serializationObject defines the JSON object
  17857. */
  17858. parse(serializationObject: any): void;
  17859. }
  17860. }
  17861. declare module BABYLON {
  17862. /**
  17863. * Particle emitter emitting particles from the inside of a sphere.
  17864. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17865. */
  17866. export class SphereParticleEmitter implements IParticleEmitterType {
  17867. /**
  17868. * The radius of the emission sphere.
  17869. */
  17870. radius: number;
  17871. /**
  17872. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17873. */
  17874. radiusRange: number;
  17875. /**
  17876. * How much to randomize the particle direction [0-1].
  17877. */
  17878. directionRandomizer: number;
  17879. /**
  17880. * Creates a new instance SphereParticleEmitter
  17881. * @param radius the radius of the emission sphere (1 by default)
  17882. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17883. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17884. */
  17885. constructor(
  17886. /**
  17887. * The radius of the emission sphere.
  17888. */
  17889. radius?: number,
  17890. /**
  17891. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17892. */
  17893. radiusRange?: number,
  17894. /**
  17895. * How much to randomize the particle direction [0-1].
  17896. */
  17897. directionRandomizer?: number);
  17898. /**
  17899. * Called by the particle System when the direction is computed for the created particle.
  17900. * @param worldMatrix is the world matrix of the particle system
  17901. * @param directionToUpdate is the direction vector to update with the result
  17902. * @param particle is the particle we are computed the direction for
  17903. */
  17904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17905. /**
  17906. * Called by the particle System when the position is computed for the created particle.
  17907. * @param worldMatrix is the world matrix of the particle system
  17908. * @param positionToUpdate is the position vector to update with the result
  17909. * @param particle is the particle we are computed the position for
  17910. */
  17911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17912. /**
  17913. * Clones the current emitter and returns a copy of it
  17914. * @returns the new emitter
  17915. */
  17916. clone(): SphereParticleEmitter;
  17917. /**
  17918. * Called by the GPUParticleSystem to setup the update shader
  17919. * @param effect defines the update shader
  17920. */
  17921. applyToShader(effect: Effect): void;
  17922. /**
  17923. * Returns a string to use to update the GPU particles update shader
  17924. * @returns a string containng the defines string
  17925. */
  17926. getEffectDefines(): string;
  17927. /**
  17928. * Returns the string "SphereParticleEmitter"
  17929. * @returns a string containing the class name
  17930. */
  17931. getClassName(): string;
  17932. /**
  17933. * Serializes the particle system to a JSON object.
  17934. * @returns the JSON object
  17935. */
  17936. serialize(): any;
  17937. /**
  17938. * Parse properties from a JSON object
  17939. * @param serializationObject defines the JSON object
  17940. */
  17941. parse(serializationObject: any): void;
  17942. }
  17943. /**
  17944. * Particle emitter emitting particles from the inside of a sphere.
  17945. * It emits the particles randomly between two vectors.
  17946. */
  17947. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17948. /**
  17949. * The min limit of the emission direction.
  17950. */
  17951. direction1: Vector3;
  17952. /**
  17953. * The max limit of the emission direction.
  17954. */
  17955. direction2: Vector3;
  17956. /**
  17957. * Creates a new instance SphereDirectedParticleEmitter
  17958. * @param radius the radius of the emission sphere (1 by default)
  17959. * @param direction1 the min limit of the emission direction (up vector by default)
  17960. * @param direction2 the max limit of the emission direction (up vector by default)
  17961. */
  17962. constructor(radius?: number,
  17963. /**
  17964. * The min limit of the emission direction.
  17965. */
  17966. direction1?: Vector3,
  17967. /**
  17968. * The max limit of the emission direction.
  17969. */
  17970. direction2?: Vector3);
  17971. /**
  17972. * Called by the particle System when the direction is computed for the created particle.
  17973. * @param worldMatrix is the world matrix of the particle system
  17974. * @param directionToUpdate is the direction vector to update with the result
  17975. * @param particle is the particle we are computed the direction for
  17976. */
  17977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17978. /**
  17979. * Clones the current emitter and returns a copy of it
  17980. * @returns the new emitter
  17981. */
  17982. clone(): SphereDirectedParticleEmitter;
  17983. /**
  17984. * Called by the GPUParticleSystem to setup the update shader
  17985. * @param effect defines the update shader
  17986. */
  17987. applyToShader(effect: Effect): void;
  17988. /**
  17989. * Returns a string to use to update the GPU particles update shader
  17990. * @returns a string containng the defines string
  17991. */
  17992. getEffectDefines(): string;
  17993. /**
  17994. * Returns the string "SphereDirectedParticleEmitter"
  17995. * @returns a string containing the class name
  17996. */
  17997. getClassName(): string;
  17998. /**
  17999. * Serializes the particle system to a JSON object.
  18000. * @returns the JSON object
  18001. */
  18002. serialize(): any;
  18003. /**
  18004. * Parse properties from a JSON object
  18005. * @param serializationObject defines the JSON object
  18006. */
  18007. parse(serializationObject: any): void;
  18008. }
  18009. }
  18010. declare module BABYLON {
  18011. /**
  18012. * Interface representing a particle system in Babylon.js.
  18013. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18014. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18015. */
  18016. export interface IParticleSystem {
  18017. /**
  18018. * List of animations used by the particle system.
  18019. */
  18020. animations: Animation[];
  18021. /**
  18022. * The id of the Particle system.
  18023. */
  18024. id: string;
  18025. /**
  18026. * The name of the Particle system.
  18027. */
  18028. name: string;
  18029. /**
  18030. * The emitter represents the Mesh or position we are attaching the particle system to.
  18031. */
  18032. emitter: Nullable<AbstractMesh | Vector3>;
  18033. /**
  18034. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18035. */
  18036. isBillboardBased: boolean;
  18037. /**
  18038. * The rendering group used by the Particle system to chose when to render.
  18039. */
  18040. renderingGroupId: number;
  18041. /**
  18042. * The layer mask we are rendering the particles through.
  18043. */
  18044. layerMask: number;
  18045. /**
  18046. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18047. */
  18048. updateSpeed: number;
  18049. /**
  18050. * The amount of time the particle system is running (depends of the overall update speed).
  18051. */
  18052. targetStopDuration: number;
  18053. /**
  18054. * The texture used to render each particle. (this can be a spritesheet)
  18055. */
  18056. particleTexture: Nullable<Texture>;
  18057. /**
  18058. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18059. */
  18060. blendMode: number;
  18061. /**
  18062. * Minimum life time of emitting particles.
  18063. */
  18064. minLifeTime: number;
  18065. /**
  18066. * Maximum life time of emitting particles.
  18067. */
  18068. maxLifeTime: number;
  18069. /**
  18070. * Minimum Size of emitting particles.
  18071. */
  18072. minSize: number;
  18073. /**
  18074. * Maximum Size of emitting particles.
  18075. */
  18076. maxSize: number;
  18077. /**
  18078. * Minimum scale of emitting particles on X axis.
  18079. */
  18080. minScaleX: number;
  18081. /**
  18082. * Maximum scale of emitting particles on X axis.
  18083. */
  18084. maxScaleX: number;
  18085. /**
  18086. * Minimum scale of emitting particles on Y axis.
  18087. */
  18088. minScaleY: number;
  18089. /**
  18090. * Maximum scale of emitting particles on Y axis.
  18091. */
  18092. maxScaleY: number;
  18093. /**
  18094. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18095. */
  18096. color1: Color4;
  18097. /**
  18098. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18099. */
  18100. color2: Color4;
  18101. /**
  18102. * Color the particle will have at the end of its lifetime.
  18103. */
  18104. colorDead: Color4;
  18105. /**
  18106. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18107. */
  18108. emitRate: number;
  18109. /**
  18110. * You can use gravity if you want to give an orientation to your particles.
  18111. */
  18112. gravity: Vector3;
  18113. /**
  18114. * Minimum power of emitting particles.
  18115. */
  18116. minEmitPower: number;
  18117. /**
  18118. * Maximum power of emitting particles.
  18119. */
  18120. maxEmitPower: number;
  18121. /**
  18122. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18123. */
  18124. minAngularSpeed: number;
  18125. /**
  18126. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18127. */
  18128. maxAngularSpeed: number;
  18129. /**
  18130. * Gets or sets the minimal initial rotation in radians.
  18131. */
  18132. minInitialRotation: number;
  18133. /**
  18134. * Gets or sets the maximal initial rotation in radians.
  18135. */
  18136. maxInitialRotation: number;
  18137. /**
  18138. * The particle emitter type defines the emitter used by the particle system.
  18139. * It can be for example box, sphere, or cone...
  18140. */
  18141. particleEmitterType: Nullable<IParticleEmitterType>;
  18142. /**
  18143. * Defines the delay in milliseconds before starting the system (0 by default)
  18144. */
  18145. startDelay: number;
  18146. /**
  18147. * 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
  18148. */
  18149. preWarmCycles: number;
  18150. /**
  18151. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18152. */
  18153. preWarmStepOffset: number;
  18154. /**
  18155. * 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)
  18156. */
  18157. spriteCellChangeSpeed: number;
  18158. /**
  18159. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18160. */
  18161. startSpriteCellID: number;
  18162. /**
  18163. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18164. */
  18165. endSpriteCellID: number;
  18166. /**
  18167. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18168. */
  18169. spriteCellWidth: number;
  18170. /**
  18171. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18172. */
  18173. spriteCellHeight: number;
  18174. /**
  18175. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18176. */
  18177. spriteRandomStartCell: boolean;
  18178. /**
  18179. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18180. */
  18181. isAnimationSheetEnabled: boolean;
  18182. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18183. translationPivot: Vector2;
  18184. /**
  18185. * Gets or sets a texture used to add random noise to particle positions
  18186. */
  18187. noiseTexture: Nullable<BaseTexture>;
  18188. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18189. noiseStrength: Vector3;
  18190. /**
  18191. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18192. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18193. */
  18194. billboardMode: number;
  18195. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18196. limitVelocityDamping: number;
  18197. /**
  18198. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18199. */
  18200. beginAnimationOnStart: boolean;
  18201. /**
  18202. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18203. */
  18204. beginAnimationFrom: number;
  18205. /**
  18206. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18207. */
  18208. beginAnimationTo: number;
  18209. /**
  18210. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18211. */
  18212. beginAnimationLoop: boolean;
  18213. /**
  18214. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18215. */
  18216. disposeOnStop: boolean;
  18217. /**
  18218. * Gets the maximum number of particles active at the same time.
  18219. * @returns The max number of active particles.
  18220. */
  18221. getCapacity(): number;
  18222. /**
  18223. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18224. * @returns True if it has been started, otherwise false.
  18225. */
  18226. isStarted(): boolean;
  18227. /**
  18228. * Animates the particle system for this frame.
  18229. */
  18230. animate(): void;
  18231. /**
  18232. * Renders the particle system in its current state.
  18233. * @returns the current number of particles
  18234. */
  18235. render(): number;
  18236. /**
  18237. * Dispose the particle system and frees its associated resources.
  18238. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18239. */
  18240. dispose(disposeTexture?: boolean): void;
  18241. /**
  18242. * Clones the particle system.
  18243. * @param name The name of the cloned object
  18244. * @param newEmitter The new emitter to use
  18245. * @returns the cloned particle system
  18246. */
  18247. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18248. /**
  18249. * Serializes the particle system to a JSON object.
  18250. * @returns the JSON object
  18251. */
  18252. serialize(): any;
  18253. /**
  18254. * Rebuild the particle system
  18255. */
  18256. rebuild(): void;
  18257. /**
  18258. * Starts the particle system and begins to emit
  18259. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18260. */
  18261. start(delay?: number): void;
  18262. /**
  18263. * Stops the particle system.
  18264. */
  18265. stop(): void;
  18266. /**
  18267. * Remove all active particles
  18268. */
  18269. reset(): void;
  18270. /**
  18271. * Is this system ready to be used/rendered
  18272. * @return true if the system is ready
  18273. */
  18274. isReady(): boolean;
  18275. /**
  18276. * Adds a new color gradient
  18277. * @param gradient defines the gradient to use (between 0 and 1)
  18278. * @param color1 defines the color to affect to the specified gradient
  18279. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18280. * @returns the current particle system
  18281. */
  18282. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18283. /**
  18284. * Remove a specific color gradient
  18285. * @param gradient defines the gradient to remove
  18286. * @returns the current particle system
  18287. */
  18288. removeColorGradient(gradient: number): IParticleSystem;
  18289. /**
  18290. * Adds a new size gradient
  18291. * @param gradient defines the gradient to use (between 0 and 1)
  18292. * @param factor defines the size factor to affect to the specified gradient
  18293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18294. * @returns the current particle system
  18295. */
  18296. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18297. /**
  18298. * Remove a specific size gradient
  18299. * @param gradient defines the gradient to remove
  18300. * @returns the current particle system
  18301. */
  18302. removeSizeGradient(gradient: number): IParticleSystem;
  18303. /**
  18304. * Gets the current list of color gradients.
  18305. * You must use addColorGradient and removeColorGradient to udpate this list
  18306. * @returns the list of color gradients
  18307. */
  18308. getColorGradients(): Nullable<Array<ColorGradient>>;
  18309. /**
  18310. * Gets the current list of size gradients.
  18311. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18312. * @returns the list of size gradients
  18313. */
  18314. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18315. /**
  18316. * Gets the current list of angular speed gradients.
  18317. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18318. * @returns the list of angular speed gradients
  18319. */
  18320. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18321. /**
  18322. * Adds a new angular speed gradient
  18323. * @param gradient defines the gradient to use (between 0 and 1)
  18324. * @param factor defines the angular speed to affect to the specified gradient
  18325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18326. * @returns the current particle system
  18327. */
  18328. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18329. /**
  18330. * Remove a specific angular speed gradient
  18331. * @param gradient defines the gradient to remove
  18332. * @returns the current particle system
  18333. */
  18334. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18335. /**
  18336. * Gets the current list of velocity gradients.
  18337. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18338. * @returns the list of velocity gradients
  18339. */
  18340. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18341. /**
  18342. * Adds a new velocity gradient
  18343. * @param gradient defines the gradient to use (between 0 and 1)
  18344. * @param factor defines the velocity to affect to the specified gradient
  18345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18346. * @returns the current particle system
  18347. */
  18348. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18349. /**
  18350. * Remove a specific velocity gradient
  18351. * @param gradient defines the gradient to remove
  18352. * @returns the current particle system
  18353. */
  18354. removeVelocityGradient(gradient: number): IParticleSystem;
  18355. /**
  18356. * Gets the current list of limit velocity gradients.
  18357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18358. * @returns the list of limit velocity gradients
  18359. */
  18360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18361. /**
  18362. * Adds a new limit velocity gradient
  18363. * @param gradient defines the gradient to use (between 0 and 1)
  18364. * @param factor defines the limit velocity to affect to the specified gradient
  18365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18366. * @returns the current particle system
  18367. */
  18368. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18369. /**
  18370. * Remove a specific limit velocity gradient
  18371. * @param gradient defines the gradient to remove
  18372. * @returns the current particle system
  18373. */
  18374. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18375. /**
  18376. * Adds a new drag gradient
  18377. * @param gradient defines the gradient to use (between 0 and 1)
  18378. * @param factor defines the drag to affect to the specified gradient
  18379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18380. * @returns the current particle system
  18381. */
  18382. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18383. /**
  18384. * Remove a specific drag gradient
  18385. * @param gradient defines the gradient to remove
  18386. * @returns the current particle system
  18387. */
  18388. removeDragGradient(gradient: number): IParticleSystem;
  18389. /**
  18390. * Gets the current list of drag gradients.
  18391. * You must use addDragGradient and removeDragGradient to udpate this list
  18392. * @returns the list of drag gradients
  18393. */
  18394. getDragGradients(): Nullable<Array<FactorGradient>>;
  18395. /**
  18396. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18397. * @param gradient defines the gradient to use (between 0 and 1)
  18398. * @param factor defines the emit rate to affect to the specified gradient
  18399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18400. * @returns the current particle system
  18401. */
  18402. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18403. /**
  18404. * Remove a specific emit rate gradient
  18405. * @param gradient defines the gradient to remove
  18406. * @returns the current particle system
  18407. */
  18408. removeEmitRateGradient(gradient: number): IParticleSystem;
  18409. /**
  18410. * Gets the current list of emit rate gradients.
  18411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18412. * @returns the list of emit rate gradients
  18413. */
  18414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18415. /**
  18416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18417. * @param gradient defines the gradient to use (between 0 and 1)
  18418. * @param factor defines the start size to affect to the specified gradient
  18419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18420. * @returns the current particle system
  18421. */
  18422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18423. /**
  18424. * Remove a specific start size gradient
  18425. * @param gradient defines the gradient to remove
  18426. * @returns the current particle system
  18427. */
  18428. removeStartSizeGradient(gradient: number): IParticleSystem;
  18429. /**
  18430. * Gets the current list of start size gradients.
  18431. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18432. * @returns the list of start size gradients
  18433. */
  18434. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18435. /**
  18436. * Adds a new life time gradient
  18437. * @param gradient defines the gradient to use (between 0 and 1)
  18438. * @param factor defines the life time factor to affect to the specified gradient
  18439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18440. * @returns the current particle system
  18441. */
  18442. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18443. /**
  18444. * Remove a specific life time gradient
  18445. * @param gradient defines the gradient to remove
  18446. * @returns the current particle system
  18447. */
  18448. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18449. /**
  18450. * Gets the current list of life time gradients.
  18451. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18452. * @returns the list of life time gradients
  18453. */
  18454. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18455. /**
  18456. * Gets the current list of color gradients.
  18457. * You must use addColorGradient and removeColorGradient to udpate this list
  18458. * @returns the list of color gradients
  18459. */
  18460. getColorGradients(): Nullable<Array<ColorGradient>>;
  18461. /**
  18462. * Adds a new ramp gradient used to remap particle colors
  18463. * @param gradient defines the gradient to use (between 0 and 1)
  18464. * @param color defines the color to affect to the specified gradient
  18465. * @returns the current particle system
  18466. */
  18467. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18468. /**
  18469. * Gets the current list of ramp gradients.
  18470. * You must use addRampGradient and removeRampGradient to udpate this list
  18471. * @returns the list of ramp gradients
  18472. */
  18473. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18474. /** Gets or sets a boolean indicating that ramp gradients must be used
  18475. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18476. */
  18477. useRampGradients: boolean;
  18478. /**
  18479. * Adds a new color remap gradient
  18480. * @param gradient defines the gradient to use (between 0 and 1)
  18481. * @param min defines the color remap minimal range
  18482. * @param max defines the color remap maximal range
  18483. * @returns the current particle system
  18484. */
  18485. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18486. /**
  18487. * Gets the current list of color remap gradients.
  18488. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18489. * @returns the list of color remap gradients
  18490. */
  18491. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18492. /**
  18493. * Adds a new alpha remap gradient
  18494. * @param gradient defines the gradient to use (between 0 and 1)
  18495. * @param min defines the alpha remap minimal range
  18496. * @param max defines the alpha remap maximal range
  18497. * @returns the current particle system
  18498. */
  18499. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18500. /**
  18501. * Gets the current list of alpha remap gradients.
  18502. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18503. * @returns the list of alpha remap gradients
  18504. */
  18505. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18506. /**
  18507. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18508. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18509. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18510. * @returns the emitter
  18511. */
  18512. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18513. /**
  18514. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18515. * @param radius The radius of the hemisphere to emit from
  18516. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18517. * @returns the emitter
  18518. */
  18519. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18520. /**
  18521. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18522. * @param radius The radius of the sphere to emit from
  18523. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18524. * @returns the emitter
  18525. */
  18526. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18527. /**
  18528. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18529. * @param radius The radius of the sphere to emit from
  18530. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18531. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18532. * @returns the emitter
  18533. */
  18534. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18535. /**
  18536. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18537. * @param radius The radius of the emission cylinder
  18538. * @param height The height of the emission cylinder
  18539. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18540. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18541. * @returns the emitter
  18542. */
  18543. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18544. /**
  18545. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18546. * @param radius The radius of the cylinder to emit from
  18547. * @param height The height of the emission cylinder
  18548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18551. * @returns the emitter
  18552. */
  18553. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18554. /**
  18555. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18556. * @param radius The radius of the cone to emit from
  18557. * @param angle The base angle of the cone
  18558. * @returns the emitter
  18559. */
  18560. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18561. /**
  18562. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18565. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18566. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18567. * @returns the emitter
  18568. */
  18569. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18570. /**
  18571. * Get hosting scene
  18572. * @returns the scene
  18573. */
  18574. getScene(): Scene;
  18575. }
  18576. }
  18577. declare module BABYLON {
  18578. /**
  18579. * Creates an instance based on a source mesh.
  18580. */
  18581. export class InstancedMesh extends AbstractMesh {
  18582. private _sourceMesh;
  18583. private _currentLOD;
  18584. /** @hidden */
  18585. _indexInSourceMeshInstanceArray: number;
  18586. constructor(name: string, source: Mesh);
  18587. /**
  18588. * Returns the string "InstancedMesh".
  18589. */
  18590. getClassName(): string;
  18591. /** Gets the list of lights affecting that mesh */
  18592. readonly lightSources: Light[];
  18593. _resyncLightSources(): void;
  18594. _resyncLighSource(light: Light): void;
  18595. _removeLightSource(light: Light, dispose: boolean): void;
  18596. /**
  18597. * If the source mesh receives shadows
  18598. */
  18599. readonly receiveShadows: boolean;
  18600. /**
  18601. * The material of the source mesh
  18602. */
  18603. readonly material: Nullable<Material>;
  18604. /**
  18605. * Visibility of the source mesh
  18606. */
  18607. readonly visibility: number;
  18608. /**
  18609. * Skeleton of the source mesh
  18610. */
  18611. readonly skeleton: Nullable<Skeleton>;
  18612. /**
  18613. * Rendering ground id of the source mesh
  18614. */
  18615. renderingGroupId: number;
  18616. /**
  18617. * Returns the total number of vertices (integer).
  18618. */
  18619. getTotalVertices(): number;
  18620. /**
  18621. * Returns a positive integer : the total number of indices in this mesh geometry.
  18622. * @returns the numner of indices or zero if the mesh has no geometry.
  18623. */
  18624. getTotalIndices(): number;
  18625. /**
  18626. * The source mesh of the instance
  18627. */
  18628. readonly sourceMesh: Mesh;
  18629. /**
  18630. * Is this node ready to be used/rendered
  18631. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18632. * @return {boolean} is it ready
  18633. */
  18634. isReady(completeCheck?: boolean): boolean;
  18635. /**
  18636. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18637. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18638. * @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.
  18639. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18640. */
  18641. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18642. /**
  18643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18645. * The `data` are either a numeric array either a Float32Array.
  18646. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18647. * 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).
  18648. * Note that a new underlying VertexBuffer object is created each call.
  18649. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18650. *
  18651. * Possible `kind` values :
  18652. * - VertexBuffer.PositionKind
  18653. * - VertexBuffer.UVKind
  18654. * - VertexBuffer.UV2Kind
  18655. * - VertexBuffer.UV3Kind
  18656. * - VertexBuffer.UV4Kind
  18657. * - VertexBuffer.UV5Kind
  18658. * - VertexBuffer.UV6Kind
  18659. * - VertexBuffer.ColorKind
  18660. * - VertexBuffer.MatricesIndicesKind
  18661. * - VertexBuffer.MatricesIndicesExtraKind
  18662. * - VertexBuffer.MatricesWeightsKind
  18663. * - VertexBuffer.MatricesWeightsExtraKind
  18664. *
  18665. * Returns the Mesh.
  18666. */
  18667. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18668. /**
  18669. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18670. * If the mesh has no geometry, it is simply returned as it is.
  18671. * The `data` are either a numeric array either a Float32Array.
  18672. * No new underlying VertexBuffer object is created.
  18673. * 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.
  18674. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18675. *
  18676. * Possible `kind` values :
  18677. * - VertexBuffer.PositionKind
  18678. * - VertexBuffer.UVKind
  18679. * - VertexBuffer.UV2Kind
  18680. * - VertexBuffer.UV3Kind
  18681. * - VertexBuffer.UV4Kind
  18682. * - VertexBuffer.UV5Kind
  18683. * - VertexBuffer.UV6Kind
  18684. * - VertexBuffer.ColorKind
  18685. * - VertexBuffer.MatricesIndicesKind
  18686. * - VertexBuffer.MatricesIndicesExtraKind
  18687. * - VertexBuffer.MatricesWeightsKind
  18688. * - VertexBuffer.MatricesWeightsExtraKind
  18689. *
  18690. * Returns the Mesh.
  18691. */
  18692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18693. /**
  18694. * Sets the mesh indices.
  18695. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18696. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18697. * This method creates a new index buffer each call.
  18698. * Returns the Mesh.
  18699. */
  18700. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18701. /**
  18702. * Boolean : True if the mesh owns the requested kind of data.
  18703. */
  18704. isVerticesDataPresent(kind: string): boolean;
  18705. /**
  18706. * Returns an array of indices (IndicesArray).
  18707. */
  18708. getIndices(): Nullable<IndicesArray>;
  18709. readonly _positions: Nullable<Vector3[]>;
  18710. /**
  18711. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18712. * This means the mesh underlying bounding box and sphere are recomputed.
  18713. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18714. * @returns the current mesh
  18715. */
  18716. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18717. /** @hidden */
  18718. _preActivate(): InstancedMesh;
  18719. /** @hidden */
  18720. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18721. /** @hidden */
  18722. _postActivate(): void;
  18723. getWorldMatrix(): Matrix;
  18724. readonly isAnInstance: boolean;
  18725. /**
  18726. * Returns the current associated LOD AbstractMesh.
  18727. */
  18728. getLOD(camera: Camera): AbstractMesh;
  18729. /** @hidden */
  18730. _syncSubMeshes(): InstancedMesh;
  18731. /** @hidden */
  18732. _generatePointsArray(): boolean;
  18733. /**
  18734. * Creates a new InstancedMesh from the current mesh.
  18735. * - name (string) : the cloned mesh name
  18736. * - newParent (optional Node) : the optional Node to parent the clone to.
  18737. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18738. *
  18739. * Returns the clone.
  18740. */
  18741. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18742. /**
  18743. * Disposes the InstancedMesh.
  18744. * Returns nothing.
  18745. */
  18746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18747. }
  18748. }
  18749. declare module BABYLON {
  18750. /**
  18751. * Defines the options associated with the creation of a shader material.
  18752. */
  18753. export interface IShaderMaterialOptions {
  18754. /**
  18755. * Does the material work in alpha blend mode
  18756. */
  18757. needAlphaBlending: boolean;
  18758. /**
  18759. * Does the material work in alpha test mode
  18760. */
  18761. needAlphaTesting: boolean;
  18762. /**
  18763. * The list of attribute names used in the shader
  18764. */
  18765. attributes: string[];
  18766. /**
  18767. * The list of unifrom names used in the shader
  18768. */
  18769. uniforms: string[];
  18770. /**
  18771. * The list of UBO names used in the shader
  18772. */
  18773. uniformBuffers: string[];
  18774. /**
  18775. * The list of sampler names used in the shader
  18776. */
  18777. samplers: string[];
  18778. /**
  18779. * The list of defines used in the shader
  18780. */
  18781. defines: string[];
  18782. }
  18783. /**
  18784. * 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.
  18785. *
  18786. * This returned material effects how the mesh will look based on the code in the shaders.
  18787. *
  18788. * @see http://doc.babylonjs.com/how_to/shader_material
  18789. */
  18790. export class ShaderMaterial extends Material {
  18791. private _shaderPath;
  18792. private _options;
  18793. private _textures;
  18794. private _textureArrays;
  18795. private _floats;
  18796. private _ints;
  18797. private _floatsArrays;
  18798. private _colors3;
  18799. private _colors3Arrays;
  18800. private _colors4;
  18801. private _colors4Arrays;
  18802. private _vectors2;
  18803. private _vectors3;
  18804. private _vectors4;
  18805. private _matrices;
  18806. private _matrices3x3;
  18807. private _matrices2x2;
  18808. private _vectors2Arrays;
  18809. private _vectors3Arrays;
  18810. private _vectors4Arrays;
  18811. private _cachedWorldViewMatrix;
  18812. private _cachedWorldViewProjectionMatrix;
  18813. private _renderId;
  18814. /**
  18815. * Instantiate a new shader material.
  18816. * 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.
  18817. * This returned material effects how the mesh will look based on the code in the shaders.
  18818. * @see http://doc.babylonjs.com/how_to/shader_material
  18819. * @param name Define the name of the material in the scene
  18820. * @param scene Define the scene the material belongs to
  18821. * @param shaderPath Defines the route to the shader code in one of three ways:
  18822. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18823. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18824. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18825. * @param options Define the options used to create the shader
  18826. */
  18827. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18828. /**
  18829. * Gets the options used to compile the shader.
  18830. * They can be modified to trigger a new compilation
  18831. */
  18832. readonly options: IShaderMaterialOptions;
  18833. /**
  18834. * Gets the current class name of the material e.g. "ShaderMaterial"
  18835. * Mainly use in serialization.
  18836. * @returns the class name
  18837. */
  18838. getClassName(): string;
  18839. /**
  18840. * Specifies if the material will require alpha blending
  18841. * @returns a boolean specifying if alpha blending is needed
  18842. */
  18843. needAlphaBlending(): boolean;
  18844. /**
  18845. * Specifies if this material should be rendered in alpha test mode
  18846. * @returns a boolean specifying if an alpha test is needed.
  18847. */
  18848. needAlphaTesting(): boolean;
  18849. private _checkUniform;
  18850. /**
  18851. * Set a texture in the shader.
  18852. * @param name Define the name of the uniform samplers as defined in the shader
  18853. * @param texture Define the texture to bind to this sampler
  18854. * @return the material itself allowing "fluent" like uniform updates
  18855. */
  18856. setTexture(name: string, texture: Texture): ShaderMaterial;
  18857. /**
  18858. * Set a texture array in the shader.
  18859. * @param name Define the name of the uniform sampler array as defined in the shader
  18860. * @param textures Define the list of textures to bind to this sampler
  18861. * @return the material itself allowing "fluent" like uniform updates
  18862. */
  18863. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18864. /**
  18865. * Set a float in the shader.
  18866. * @param name Define the name of the uniform as defined in the shader
  18867. * @param value Define the value to give to the uniform
  18868. * @return the material itself allowing "fluent" like uniform updates
  18869. */
  18870. setFloat(name: string, value: number): ShaderMaterial;
  18871. /**
  18872. * Set a int in the shader.
  18873. * @param name Define the name of the uniform as defined in the shader
  18874. * @param value Define the value to give to the uniform
  18875. * @return the material itself allowing "fluent" like uniform updates
  18876. */
  18877. setInt(name: string, value: number): ShaderMaterial;
  18878. /**
  18879. * Set an array of floats in the shader.
  18880. * @param name Define the name of the uniform as defined in the shader
  18881. * @param value Define the value to give to the uniform
  18882. * @return the material itself allowing "fluent" like uniform updates
  18883. */
  18884. setFloats(name: string, value: number[]): ShaderMaterial;
  18885. /**
  18886. * Set a vec3 in the shader from a Color3.
  18887. * @param name Define the name of the uniform as defined in the shader
  18888. * @param value Define the value to give to the uniform
  18889. * @return the material itself allowing "fluent" like uniform updates
  18890. */
  18891. setColor3(name: string, value: Color3): ShaderMaterial;
  18892. /**
  18893. * Set a vec3 array in the shader from a Color3 array.
  18894. * @param name Define the name of the uniform as defined in the shader
  18895. * @param value Define the value to give to the uniform
  18896. * @return the material itself allowing "fluent" like uniform updates
  18897. */
  18898. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18899. /**
  18900. * Set a vec4 in the shader from a Color4.
  18901. * @param name Define the name of the uniform as defined in the shader
  18902. * @param value Define the value to give to the uniform
  18903. * @return the material itself allowing "fluent" like uniform updates
  18904. */
  18905. setColor4(name: string, value: Color4): ShaderMaterial;
  18906. /**
  18907. * Set a vec4 array in the shader from a Color4 array.
  18908. * @param name Define the name of the uniform as defined in the shader
  18909. * @param value Define the value to give to the uniform
  18910. * @return the material itself allowing "fluent" like uniform updates
  18911. */
  18912. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18913. /**
  18914. * Set a vec2 in the shader from a Vector2.
  18915. * @param name Define the name of the uniform as defined in the shader
  18916. * @param value Define the value to give to the uniform
  18917. * @return the material itself allowing "fluent" like uniform updates
  18918. */
  18919. setVector2(name: string, value: Vector2): ShaderMaterial;
  18920. /**
  18921. * Set a vec3 in the shader from a Vector3.
  18922. * @param name Define the name of the uniform as defined in the shader
  18923. * @param value Define the value to give to the uniform
  18924. * @return the material itself allowing "fluent" like uniform updates
  18925. */
  18926. setVector3(name: string, value: Vector3): ShaderMaterial;
  18927. /**
  18928. * Set a vec4 in the shader from a Vector4.
  18929. * @param name Define the name of the uniform as defined in the shader
  18930. * @param value Define the value to give to the uniform
  18931. * @return the material itself allowing "fluent" like uniform updates
  18932. */
  18933. setVector4(name: string, value: Vector4): ShaderMaterial;
  18934. /**
  18935. * Set a mat4 in the shader from a Matrix.
  18936. * @param name Define the name of the uniform as defined in the shader
  18937. * @param value Define the value to give to the uniform
  18938. * @return the material itself allowing "fluent" like uniform updates
  18939. */
  18940. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18941. /**
  18942. * Set a mat3 in the shader from a Float32Array.
  18943. * @param name Define the name of the uniform as defined in the shader
  18944. * @param value Define the value to give to the uniform
  18945. * @return the material itself allowing "fluent" like uniform updates
  18946. */
  18947. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18948. /**
  18949. * Set a mat2 in the shader from a Float32Array.
  18950. * @param name Define the name of the uniform as defined in the shader
  18951. * @param value Define the value to give to the uniform
  18952. * @return the material itself allowing "fluent" like uniform updates
  18953. */
  18954. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18955. /**
  18956. * Set a vec2 array in the shader from a number array.
  18957. * @param name Define the name of the uniform as defined in the shader
  18958. * @param value Define the value to give to the uniform
  18959. * @return the material itself allowing "fluent" like uniform updates
  18960. */
  18961. setArray2(name: string, value: number[]): ShaderMaterial;
  18962. /**
  18963. * Set a vec3 array in the shader from a number array.
  18964. * @param name Define the name of the uniform as defined in the shader
  18965. * @param value Define the value to give to the uniform
  18966. * @return the material itself allowing "fluent" like uniform updates
  18967. */
  18968. setArray3(name: string, value: number[]): ShaderMaterial;
  18969. /**
  18970. * Set a vec4 array in the shader from a number array.
  18971. * @param name Define the name of the uniform as defined in the shader
  18972. * @param value Define the value to give to the uniform
  18973. * @return the material itself allowing "fluent" like uniform updates
  18974. */
  18975. setArray4(name: string, value: number[]): ShaderMaterial;
  18976. private _checkCache;
  18977. /**
  18978. * Specifies that the submesh is ready to be used
  18979. * @param mesh defines the mesh to check
  18980. * @param subMesh defines which submesh to check
  18981. * @param useInstances specifies that instances should be used
  18982. * @returns a boolean indicating that the submesh is ready or not
  18983. */
  18984. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18985. /**
  18986. * Checks if the material is ready to render the requested mesh
  18987. * @param mesh Define the mesh to render
  18988. * @param useInstances Define whether or not the material is used with instances
  18989. * @returns true if ready, otherwise false
  18990. */
  18991. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18992. /**
  18993. * Binds the world matrix to the material
  18994. * @param world defines the world transformation matrix
  18995. */
  18996. bindOnlyWorldMatrix(world: Matrix): void;
  18997. /**
  18998. * Binds the material to the mesh
  18999. * @param world defines the world transformation matrix
  19000. * @param mesh defines the mesh to bind the material to
  19001. */
  19002. bind(world: Matrix, mesh?: Mesh): void;
  19003. /**
  19004. * Gets the active textures from the material
  19005. * @returns an array of textures
  19006. */
  19007. getActiveTextures(): BaseTexture[];
  19008. /**
  19009. * Specifies if the material uses a texture
  19010. * @param texture defines the texture to check against the material
  19011. * @returns a boolean specifying if the material uses the texture
  19012. */
  19013. hasTexture(texture: BaseTexture): boolean;
  19014. /**
  19015. * Makes a duplicate of the material, and gives it a new name
  19016. * @param name defines the new name for the duplicated material
  19017. * @returns the cloned material
  19018. */
  19019. clone(name: string): ShaderMaterial;
  19020. /**
  19021. * Disposes the material
  19022. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19023. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19024. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19025. */
  19026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19027. /**
  19028. * Serializes this material in a JSON representation
  19029. * @returns the serialized material object
  19030. */
  19031. serialize(): any;
  19032. /**
  19033. * Creates a shader material from parsed shader material data
  19034. * @param source defines the JSON represnetation of the material
  19035. * @param scene defines the hosting scene
  19036. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19037. * @returns a new material
  19038. */
  19039. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19040. }
  19041. }
  19042. declare module BABYLON {
  19043. /** @hidden */
  19044. export var colorPixelShader: {
  19045. name: string;
  19046. shader: string;
  19047. };
  19048. }
  19049. declare module BABYLON {
  19050. /** @hidden */
  19051. export var colorVertexShader: {
  19052. name: string;
  19053. shader: string;
  19054. };
  19055. }
  19056. declare module BABYLON {
  19057. /**
  19058. * Line mesh
  19059. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19060. */
  19061. export class LinesMesh extends Mesh {
  19062. /**
  19063. * If vertex color should be applied to the mesh
  19064. */
  19065. readonly useVertexColor?: boolean | undefined;
  19066. /**
  19067. * If vertex alpha should be applied to the mesh
  19068. */
  19069. readonly useVertexAlpha?: boolean | undefined;
  19070. /**
  19071. * Color of the line (Default: White)
  19072. */
  19073. color: Color3;
  19074. /**
  19075. * Alpha of the line (Default: 1)
  19076. */
  19077. alpha: number;
  19078. /**
  19079. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19080. * This margin is expressed in world space coordinates, so its value may vary.
  19081. * Default value is 0.1
  19082. */
  19083. intersectionThreshold: number;
  19084. private _colorShader;
  19085. private color4;
  19086. /**
  19087. * Creates a new LinesMesh
  19088. * @param name defines the name
  19089. * @param scene defines the hosting scene
  19090. * @param parent defines the parent mesh if any
  19091. * @param source defines the optional source LinesMesh used to clone data from
  19092. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19093. * When false, achieved by calling a clone(), also passing False.
  19094. * This will make creation of children, recursive.
  19095. * @param useVertexColor defines if this LinesMesh supports vertex color
  19096. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19097. */
  19098. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19099. /**
  19100. * If vertex color should be applied to the mesh
  19101. */
  19102. useVertexColor?: boolean | undefined,
  19103. /**
  19104. * If vertex alpha should be applied to the mesh
  19105. */
  19106. useVertexAlpha?: boolean | undefined);
  19107. private _addClipPlaneDefine;
  19108. private _removeClipPlaneDefine;
  19109. isReady(): boolean;
  19110. /**
  19111. * Returns the string "LineMesh"
  19112. */
  19113. getClassName(): string;
  19114. /**
  19115. * @hidden
  19116. */
  19117. /**
  19118. * @hidden
  19119. */
  19120. material: Material;
  19121. /**
  19122. * @hidden
  19123. */
  19124. readonly checkCollisions: boolean;
  19125. /** @hidden */
  19126. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19127. /** @hidden */
  19128. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19129. /**
  19130. * Disposes of the line mesh
  19131. * @param doNotRecurse If children should be disposed
  19132. */
  19133. dispose(doNotRecurse?: boolean): void;
  19134. /**
  19135. * Returns a new LineMesh object cloned from the current one.
  19136. */
  19137. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19138. /**
  19139. * Creates a new InstancedLinesMesh object from the mesh model.
  19140. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19141. * @param name defines the name of the new instance
  19142. * @returns a new InstancedLinesMesh
  19143. */
  19144. createInstance(name: string): InstancedLinesMesh;
  19145. }
  19146. /**
  19147. * Creates an instance based on a source LinesMesh
  19148. */
  19149. export class InstancedLinesMesh extends InstancedMesh {
  19150. /**
  19151. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19152. * This margin is expressed in world space coordinates, so its value may vary.
  19153. * Initilized with the intersectionThreshold value of the source LinesMesh
  19154. */
  19155. intersectionThreshold: number;
  19156. constructor(name: string, source: LinesMesh);
  19157. /**
  19158. * Returns the string "InstancedLinesMesh".
  19159. */
  19160. getClassName(): string;
  19161. }
  19162. }
  19163. declare module BABYLON {
  19164. /** @hidden */
  19165. export var linePixelShader: {
  19166. name: string;
  19167. shader: string;
  19168. };
  19169. }
  19170. declare module BABYLON {
  19171. /** @hidden */
  19172. export var lineVertexShader: {
  19173. name: string;
  19174. shader: string;
  19175. };
  19176. }
  19177. declare module BABYLON {
  19178. interface AbstractMesh {
  19179. /**
  19180. * Gets the edgesRenderer associated with the mesh
  19181. */
  19182. edgesRenderer: Nullable<EdgesRenderer>;
  19183. }
  19184. interface LinesMesh {
  19185. /**
  19186. * Enables the edge rendering mode on the mesh.
  19187. * This mode makes the mesh edges visible
  19188. * @param epsilon defines the maximal distance between two angles to detect a face
  19189. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19190. * @returns the currentAbstractMesh
  19191. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19192. */
  19193. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19194. }
  19195. interface InstancedLinesMesh {
  19196. /**
  19197. * Enables the edge rendering mode on the mesh.
  19198. * This mode makes the mesh edges visible
  19199. * @param epsilon defines the maximal distance between two angles to detect a face
  19200. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19201. * @returns the current InstancedLinesMesh
  19202. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19203. */
  19204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19205. }
  19206. /**
  19207. * Defines the minimum contract an Edges renderer should follow.
  19208. */
  19209. export interface IEdgesRenderer extends IDisposable {
  19210. /**
  19211. * Gets or sets a boolean indicating if the edgesRenderer is active
  19212. */
  19213. isEnabled: boolean;
  19214. /**
  19215. * Renders the edges of the attached mesh,
  19216. */
  19217. render(): void;
  19218. /**
  19219. * Checks wether or not the edges renderer is ready to render.
  19220. * @return true if ready, otherwise false.
  19221. */
  19222. isReady(): boolean;
  19223. }
  19224. /**
  19225. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19226. */
  19227. export class EdgesRenderer implements IEdgesRenderer {
  19228. /**
  19229. * Define the size of the edges with an orthographic camera
  19230. */
  19231. edgesWidthScalerForOrthographic: number;
  19232. /**
  19233. * Define the size of the edges with a perspective camera
  19234. */
  19235. edgesWidthScalerForPerspective: number;
  19236. protected _source: AbstractMesh;
  19237. protected _linesPositions: number[];
  19238. protected _linesNormals: number[];
  19239. protected _linesIndices: number[];
  19240. protected _epsilon: number;
  19241. protected _indicesCount: number;
  19242. protected _lineShader: ShaderMaterial;
  19243. protected _ib: DataBuffer;
  19244. protected _buffers: {
  19245. [key: string]: Nullable<VertexBuffer>;
  19246. };
  19247. protected _checkVerticesInsteadOfIndices: boolean;
  19248. private _meshRebuildObserver;
  19249. private _meshDisposeObserver;
  19250. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19251. isEnabled: boolean;
  19252. /**
  19253. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19254. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19255. * @param source Mesh used to create edges
  19256. * @param epsilon sum of angles in adjacency to check for edge
  19257. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19258. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19259. */
  19260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19261. protected _prepareRessources(): void;
  19262. /** @hidden */
  19263. _rebuild(): void;
  19264. /**
  19265. * Releases the required resources for the edges renderer
  19266. */
  19267. dispose(): void;
  19268. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19269. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19270. /**
  19271. * Checks if the pair of p0 and p1 is en edge
  19272. * @param faceIndex
  19273. * @param edge
  19274. * @param faceNormals
  19275. * @param p0
  19276. * @param p1
  19277. * @private
  19278. */
  19279. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19280. /**
  19281. * push line into the position, normal and index buffer
  19282. * @protected
  19283. */
  19284. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19285. /**
  19286. * Generates lines edges from adjacencjes
  19287. * @private
  19288. */
  19289. _generateEdgesLines(): void;
  19290. /**
  19291. * Checks wether or not the edges renderer is ready to render.
  19292. * @return true if ready, otherwise false.
  19293. */
  19294. isReady(): boolean;
  19295. /**
  19296. * Renders the edges of the attached mesh,
  19297. */
  19298. render(): void;
  19299. }
  19300. /**
  19301. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19302. */
  19303. export class LineEdgesRenderer extends EdgesRenderer {
  19304. /**
  19305. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19306. * @param source LineMesh used to generate edges
  19307. * @param epsilon not important (specified angle for edge detection)
  19308. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19309. */
  19310. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19311. /**
  19312. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19313. */
  19314. _generateEdgesLines(): void;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * This represents the object necessary to create a rendering group.
  19320. * This is exclusively used and created by the rendering manager.
  19321. * To modify the behavior, you use the available helpers in your scene or meshes.
  19322. * @hidden
  19323. */
  19324. export class RenderingGroup {
  19325. index: number;
  19326. private static _zeroVector;
  19327. private _scene;
  19328. private _opaqueSubMeshes;
  19329. private _transparentSubMeshes;
  19330. private _alphaTestSubMeshes;
  19331. private _depthOnlySubMeshes;
  19332. private _particleSystems;
  19333. private _spriteManagers;
  19334. private _opaqueSortCompareFn;
  19335. private _alphaTestSortCompareFn;
  19336. private _transparentSortCompareFn;
  19337. private _renderOpaque;
  19338. private _renderAlphaTest;
  19339. private _renderTransparent;
  19340. /** @hidden */
  19341. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19342. onBeforeTransparentRendering: () => void;
  19343. /**
  19344. * Set the opaque sort comparison function.
  19345. * If null the sub meshes will be render in the order they were created
  19346. */
  19347. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19348. /**
  19349. * Set the alpha test sort comparison function.
  19350. * If null the sub meshes will be render in the order they were created
  19351. */
  19352. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19353. /**
  19354. * Set the transparent sort comparison function.
  19355. * If null the sub meshes will be render in the order they were created
  19356. */
  19357. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19358. /**
  19359. * Creates a new rendering group.
  19360. * @param index The rendering group index
  19361. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19362. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19363. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19364. */
  19365. 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>);
  19366. /**
  19367. * Render all the sub meshes contained in the group.
  19368. * @param customRenderFunction Used to override the default render behaviour of the group.
  19369. * @returns true if rendered some submeshes.
  19370. */
  19371. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19372. /**
  19373. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19374. * @param subMeshes The submeshes to render
  19375. */
  19376. private renderOpaqueSorted;
  19377. /**
  19378. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19379. * @param subMeshes The submeshes to render
  19380. */
  19381. private renderAlphaTestSorted;
  19382. /**
  19383. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19384. * @param subMeshes The submeshes to render
  19385. */
  19386. private renderTransparentSorted;
  19387. /**
  19388. * Renders the submeshes in a specified order.
  19389. * @param subMeshes The submeshes to sort before render
  19390. * @param sortCompareFn The comparison function use to sort
  19391. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19392. * @param transparent Specifies to activate blending if true
  19393. */
  19394. private static renderSorted;
  19395. /**
  19396. * Renders the submeshes in the order they were dispatched (no sort applied).
  19397. * @param subMeshes The submeshes to render
  19398. */
  19399. private static renderUnsorted;
  19400. /**
  19401. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19402. * are rendered back to front if in the same alpha index.
  19403. *
  19404. * @param a The first submesh
  19405. * @param b The second submesh
  19406. * @returns The result of the comparison
  19407. */
  19408. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19409. /**
  19410. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19411. * are rendered back to front.
  19412. *
  19413. * @param a The first submesh
  19414. * @param b The second submesh
  19415. * @returns The result of the comparison
  19416. */
  19417. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19418. /**
  19419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19420. * are rendered front to back (prevent overdraw).
  19421. *
  19422. * @param a The first submesh
  19423. * @param b The second submesh
  19424. * @returns The result of the comparison
  19425. */
  19426. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19427. /**
  19428. * Resets the different lists of submeshes to prepare a new frame.
  19429. */
  19430. prepare(): void;
  19431. dispose(): void;
  19432. /**
  19433. * Inserts the submesh in its correct queue depending on its material.
  19434. * @param subMesh The submesh to dispatch
  19435. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19436. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19437. */
  19438. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19439. dispatchSprites(spriteManager: ISpriteManager): void;
  19440. dispatchParticles(particleSystem: IParticleSystem): void;
  19441. private _renderParticles;
  19442. private _renderSprites;
  19443. }
  19444. }
  19445. declare module BABYLON {
  19446. /**
  19447. * Interface describing the different options available in the rendering manager
  19448. * regarding Auto Clear between groups.
  19449. */
  19450. export interface IRenderingManagerAutoClearSetup {
  19451. /**
  19452. * Defines whether or not autoclear is enable.
  19453. */
  19454. autoClear: boolean;
  19455. /**
  19456. * Defines whether or not to autoclear the depth buffer.
  19457. */
  19458. depth: boolean;
  19459. /**
  19460. * Defines whether or not to autoclear the stencil buffer.
  19461. */
  19462. stencil: boolean;
  19463. }
  19464. /**
  19465. * This class is used by the onRenderingGroupObservable
  19466. */
  19467. export class RenderingGroupInfo {
  19468. /**
  19469. * The Scene that being rendered
  19470. */
  19471. scene: Scene;
  19472. /**
  19473. * The camera currently used for the rendering pass
  19474. */
  19475. camera: Nullable<Camera>;
  19476. /**
  19477. * The ID of the renderingGroup being processed
  19478. */
  19479. renderingGroupId: number;
  19480. }
  19481. /**
  19482. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19483. * It is enable to manage the different groups as well as the different necessary sort functions.
  19484. * This should not be used directly aside of the few static configurations
  19485. */
  19486. export class RenderingManager {
  19487. /**
  19488. * The max id used for rendering groups (not included)
  19489. */
  19490. static MAX_RENDERINGGROUPS: number;
  19491. /**
  19492. * The min id used for rendering groups (included)
  19493. */
  19494. static MIN_RENDERINGGROUPS: number;
  19495. /**
  19496. * Used to globally prevent autoclearing scenes.
  19497. */
  19498. static AUTOCLEAR: boolean;
  19499. /**
  19500. * @hidden
  19501. */
  19502. _useSceneAutoClearSetup: boolean;
  19503. private _scene;
  19504. private _renderingGroups;
  19505. private _depthStencilBufferAlreadyCleaned;
  19506. private _autoClearDepthStencil;
  19507. private _customOpaqueSortCompareFn;
  19508. private _customAlphaTestSortCompareFn;
  19509. private _customTransparentSortCompareFn;
  19510. private _renderingGroupInfo;
  19511. /**
  19512. * Instantiates a new rendering group for a particular scene
  19513. * @param scene Defines the scene the groups belongs to
  19514. */
  19515. constructor(scene: Scene);
  19516. private _clearDepthStencilBuffer;
  19517. /**
  19518. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19519. * @hidden
  19520. */
  19521. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19522. /**
  19523. * Resets the different information of the group to prepare a new frame
  19524. * @hidden
  19525. */
  19526. reset(): void;
  19527. /**
  19528. * Dispose and release the group and its associated resources.
  19529. * @hidden
  19530. */
  19531. dispose(): void;
  19532. /**
  19533. * Clear the info related to rendering groups preventing retention points during dispose.
  19534. */
  19535. freeRenderingGroups(): void;
  19536. private _prepareRenderingGroup;
  19537. /**
  19538. * Add a sprite manager to the rendering manager in order to render it this frame.
  19539. * @param spriteManager Define the sprite manager to render
  19540. */
  19541. dispatchSprites(spriteManager: ISpriteManager): void;
  19542. /**
  19543. * Add a particle system to the rendering manager in order to render it this frame.
  19544. * @param particleSystem Define the particle system to render
  19545. */
  19546. dispatchParticles(particleSystem: IParticleSystem): void;
  19547. /**
  19548. * Add a submesh to the manager in order to render it this frame
  19549. * @param subMesh The submesh to dispatch
  19550. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19551. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19552. */
  19553. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19554. /**
  19555. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19556. * This allowed control for front to back rendering or reversly depending of the special needs.
  19557. *
  19558. * @param renderingGroupId The rendering group id corresponding to its index
  19559. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19560. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19561. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19562. */
  19563. 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;
  19564. /**
  19565. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19566. *
  19567. * @param renderingGroupId The rendering group id corresponding to its index
  19568. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19569. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19570. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19571. */
  19572. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19573. /**
  19574. * Gets the current auto clear configuration for one rendering group of the rendering
  19575. * manager.
  19576. * @param index the rendering group index to get the information for
  19577. * @returns The auto clear setup for the requested rendering group
  19578. */
  19579. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19580. }
  19581. }
  19582. declare module BABYLON {
  19583. /**
  19584. * This Helps creating a texture that will be created from a camera in your scene.
  19585. * It is basically a dynamic texture that could be used to create special effects for instance.
  19586. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19587. */
  19588. export class RenderTargetTexture extends Texture {
  19589. isCube: boolean;
  19590. /**
  19591. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19592. */
  19593. static readonly REFRESHRATE_RENDER_ONCE: number;
  19594. /**
  19595. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19596. */
  19597. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19598. /**
  19599. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19600. * the central point of your effect and can save a lot of performances.
  19601. */
  19602. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19603. /**
  19604. * Use this predicate to dynamically define the list of mesh you want to render.
  19605. * If set, the renderList property will be overwritten.
  19606. */
  19607. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19608. private _renderList;
  19609. /**
  19610. * Use this list to define the list of mesh you want to render.
  19611. */
  19612. renderList: Nullable<Array<AbstractMesh>>;
  19613. private _hookArray;
  19614. /**
  19615. * Define if particles should be rendered in your texture.
  19616. */
  19617. renderParticles: boolean;
  19618. /**
  19619. * Define if sprites should be rendered in your texture.
  19620. */
  19621. renderSprites: boolean;
  19622. /**
  19623. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19624. */
  19625. coordinatesMode: number;
  19626. /**
  19627. * Define the camera used to render the texture.
  19628. */
  19629. activeCamera: Nullable<Camera>;
  19630. /**
  19631. * Override the render function of the texture with your own one.
  19632. */
  19633. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19634. /**
  19635. * Define if camera post processes should be use while rendering the texture.
  19636. */
  19637. useCameraPostProcesses: boolean;
  19638. /**
  19639. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19640. */
  19641. ignoreCameraViewport: boolean;
  19642. private _postProcessManager;
  19643. private _postProcesses;
  19644. private _resizeObserver;
  19645. /**
  19646. * An event triggered when the texture is unbind.
  19647. */
  19648. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19649. /**
  19650. * An event triggered when the texture is unbind.
  19651. */
  19652. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19653. private _onAfterUnbindObserver;
  19654. /**
  19655. * Set a after unbind callback in the texture.
  19656. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19657. */
  19658. onAfterUnbind: () => void;
  19659. /**
  19660. * An event triggered before rendering the texture
  19661. */
  19662. onBeforeRenderObservable: Observable<number>;
  19663. private _onBeforeRenderObserver;
  19664. /**
  19665. * Set a before render callback in the texture.
  19666. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19667. */
  19668. onBeforeRender: (faceIndex: number) => void;
  19669. /**
  19670. * An event triggered after rendering the texture
  19671. */
  19672. onAfterRenderObservable: Observable<number>;
  19673. private _onAfterRenderObserver;
  19674. /**
  19675. * Set a after render callback in the texture.
  19676. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19677. */
  19678. onAfterRender: (faceIndex: number) => void;
  19679. /**
  19680. * An event triggered after the texture clear
  19681. */
  19682. onClearObservable: Observable<Engine>;
  19683. private _onClearObserver;
  19684. /**
  19685. * Set a clear callback in the texture.
  19686. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19687. */
  19688. onClear: (Engine: Engine) => void;
  19689. /**
  19690. * An event triggered when the texture is resized.
  19691. */
  19692. onResizeObservable: Observable<RenderTargetTexture>;
  19693. /**
  19694. * Define the clear color of the Render Target if it should be different from the scene.
  19695. */
  19696. clearColor: Color4;
  19697. protected _size: number | {
  19698. width: number;
  19699. height: number;
  19700. };
  19701. protected _initialSizeParameter: number | {
  19702. width: number;
  19703. height: number;
  19704. } | {
  19705. ratio: number;
  19706. };
  19707. protected _sizeRatio: Nullable<number>;
  19708. /** @hidden */
  19709. _generateMipMaps: boolean;
  19710. protected _renderingManager: RenderingManager;
  19711. /** @hidden */
  19712. _waitingRenderList: string[];
  19713. protected _doNotChangeAspectRatio: boolean;
  19714. protected _currentRefreshId: number;
  19715. protected _refreshRate: number;
  19716. protected _textureMatrix: Matrix;
  19717. protected _samples: number;
  19718. protected _renderTargetOptions: RenderTargetCreationOptions;
  19719. /**
  19720. * Gets render target creation options that were used.
  19721. */
  19722. readonly renderTargetOptions: RenderTargetCreationOptions;
  19723. protected _engine: Engine;
  19724. protected _onRatioRescale(): void;
  19725. /**
  19726. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19727. * It must define where the camera used to render the texture is set
  19728. */
  19729. boundingBoxPosition: Vector3;
  19730. private _boundingBoxSize;
  19731. /**
  19732. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19733. * When defined, the cubemap will switch to local mode
  19734. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19735. * @example https://www.babylonjs-playground.com/#RNASML
  19736. */
  19737. boundingBoxSize: Vector3;
  19738. /**
  19739. * In case the RTT has been created with a depth texture, get the associated
  19740. * depth texture.
  19741. * Otherwise, return null.
  19742. */
  19743. depthStencilTexture: Nullable<InternalTexture>;
  19744. /**
  19745. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19746. * or used a shadow, depth texture...
  19747. * @param name The friendly name of the texture
  19748. * @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)
  19749. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19750. * @param generateMipMaps True if mip maps need to be generated after render.
  19751. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19752. * @param type The type of the buffer in the RTT (int, half float, float...)
  19753. * @param isCube True if a cube texture needs to be created
  19754. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19755. * @param generateDepthBuffer True to generate a depth buffer
  19756. * @param generateStencilBuffer True to generate a stencil buffer
  19757. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19758. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19759. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19760. */
  19761. constructor(name: string, size: number | {
  19762. width: number;
  19763. height: number;
  19764. } | {
  19765. ratio: number;
  19766. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19767. /**
  19768. * Creates a depth stencil texture.
  19769. * This is only available in WebGL 2 or with the depth texture extension available.
  19770. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19771. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19772. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19773. */
  19774. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19775. private _processSizeParameter;
  19776. /**
  19777. * Define the number of samples to use in case of MSAA.
  19778. * It defaults to one meaning no MSAA has been enabled.
  19779. */
  19780. samples: number;
  19781. /**
  19782. * Resets the refresh counter of the texture and start bak from scratch.
  19783. * Could be useful to regenerate the texture if it is setup to render only once.
  19784. */
  19785. resetRefreshCounter(): void;
  19786. /**
  19787. * Define the refresh rate of the texture or the rendering frequency.
  19788. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19789. */
  19790. refreshRate: number;
  19791. /**
  19792. * Adds a post process to the render target rendering passes.
  19793. * @param postProcess define the post process to add
  19794. */
  19795. addPostProcess(postProcess: PostProcess): void;
  19796. /**
  19797. * Clear all the post processes attached to the render target
  19798. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19799. */
  19800. clearPostProcesses(dispose?: boolean): void;
  19801. /**
  19802. * Remove one of the post process from the list of attached post processes to the texture
  19803. * @param postProcess define the post process to remove from the list
  19804. */
  19805. removePostProcess(postProcess: PostProcess): void;
  19806. /** @hidden */
  19807. _shouldRender(): boolean;
  19808. /**
  19809. * Gets the actual render size of the texture.
  19810. * @returns the width of the render size
  19811. */
  19812. getRenderSize(): number;
  19813. /**
  19814. * Gets the actual render width of the texture.
  19815. * @returns the width of the render size
  19816. */
  19817. getRenderWidth(): number;
  19818. /**
  19819. * Gets the actual render height of the texture.
  19820. * @returns the height of the render size
  19821. */
  19822. getRenderHeight(): number;
  19823. /**
  19824. * Get if the texture can be rescaled or not.
  19825. */
  19826. readonly canRescale: boolean;
  19827. /**
  19828. * Resize the texture using a ratio.
  19829. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19830. */
  19831. scale(ratio: number): void;
  19832. /**
  19833. * Get the texture reflection matrix used to rotate/transform the reflection.
  19834. * @returns the reflection matrix
  19835. */
  19836. getReflectionTextureMatrix(): Matrix;
  19837. /**
  19838. * Resize the texture to a new desired size.
  19839. * Be carrefull as it will recreate all the data in the new texture.
  19840. * @param size Define the new size. It can be:
  19841. * - a number for squared texture,
  19842. * - an object containing { width: number, height: number }
  19843. * - or an object containing a ratio { ratio: number }
  19844. */
  19845. resize(size: number | {
  19846. width: number;
  19847. height: number;
  19848. } | {
  19849. ratio: number;
  19850. }): void;
  19851. /**
  19852. * Renders all the objects from the render list into the texture.
  19853. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19854. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19855. */
  19856. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19857. private _bestReflectionRenderTargetDimension;
  19858. /**
  19859. * @hidden
  19860. * @param faceIndex face index to bind to if this is a cubetexture
  19861. */
  19862. _bindFrameBuffer(faceIndex?: number): void;
  19863. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19864. private renderToTarget;
  19865. /**
  19866. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19867. * This allowed control for front to back rendering or reversly depending of the special needs.
  19868. *
  19869. * @param renderingGroupId The rendering group id corresponding to its index
  19870. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19871. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19872. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19873. */
  19874. 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;
  19875. /**
  19876. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19877. *
  19878. * @param renderingGroupId The rendering group id corresponding to its index
  19879. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19880. */
  19881. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19882. /**
  19883. * Clones the texture.
  19884. * @returns the cloned texture
  19885. */
  19886. clone(): RenderTargetTexture;
  19887. /**
  19888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19889. * @returns The JSON representation of the texture
  19890. */
  19891. serialize(): any;
  19892. /**
  19893. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19894. */
  19895. disposeFramebufferObjects(): void;
  19896. /**
  19897. * Dispose the texture and release its associated resources.
  19898. */
  19899. dispose(): void;
  19900. /** @hidden */
  19901. _rebuild(): void;
  19902. /**
  19903. * Clear the info related to rendering groups preventing retention point in material dispose.
  19904. */
  19905. freeRenderingGroups(): void;
  19906. /**
  19907. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19908. * @returns the view count
  19909. */
  19910. getViewCount(): number;
  19911. }
  19912. }
  19913. declare module BABYLON {
  19914. /**
  19915. * Base class for the main features of a material in Babylon.js
  19916. */
  19917. export class Material implements IAnimatable {
  19918. /**
  19919. * Returns the triangle fill mode
  19920. */
  19921. static readonly TriangleFillMode: number;
  19922. /**
  19923. * Returns the wireframe mode
  19924. */
  19925. static readonly WireFrameFillMode: number;
  19926. /**
  19927. * Returns the point fill mode
  19928. */
  19929. static readonly PointFillMode: number;
  19930. /**
  19931. * Returns the point list draw mode
  19932. */
  19933. static readonly PointListDrawMode: number;
  19934. /**
  19935. * Returns the line list draw mode
  19936. */
  19937. static readonly LineListDrawMode: number;
  19938. /**
  19939. * Returns the line loop draw mode
  19940. */
  19941. static readonly LineLoopDrawMode: number;
  19942. /**
  19943. * Returns the line strip draw mode
  19944. */
  19945. static readonly LineStripDrawMode: number;
  19946. /**
  19947. * Returns the triangle strip draw mode
  19948. */
  19949. static readonly TriangleStripDrawMode: number;
  19950. /**
  19951. * Returns the triangle fan draw mode
  19952. */
  19953. static readonly TriangleFanDrawMode: number;
  19954. /**
  19955. * Stores the clock-wise side orientation
  19956. */
  19957. static readonly ClockWiseSideOrientation: number;
  19958. /**
  19959. * Stores the counter clock-wise side orientation
  19960. */
  19961. static readonly CounterClockWiseSideOrientation: number;
  19962. /**
  19963. * The dirty texture flag value
  19964. */
  19965. static readonly TextureDirtyFlag: number;
  19966. /**
  19967. * The dirty light flag value
  19968. */
  19969. static readonly LightDirtyFlag: number;
  19970. /**
  19971. * The dirty fresnel flag value
  19972. */
  19973. static readonly FresnelDirtyFlag: number;
  19974. /**
  19975. * The dirty attribute flag value
  19976. */
  19977. static readonly AttributesDirtyFlag: number;
  19978. /**
  19979. * The dirty misc flag value
  19980. */
  19981. static readonly MiscDirtyFlag: number;
  19982. /**
  19983. * The all dirty flag value
  19984. */
  19985. static readonly AllDirtyFlag: number;
  19986. /**
  19987. * The ID of the material
  19988. */
  19989. id: string;
  19990. /**
  19991. * Gets or sets the unique id of the material
  19992. */
  19993. uniqueId: number;
  19994. /**
  19995. * The name of the material
  19996. */
  19997. name: string;
  19998. /**
  19999. * Gets or sets user defined metadata
  20000. */
  20001. metadata: any;
  20002. /**
  20003. * For internal use only. Please do not use.
  20004. */
  20005. reservedDataStore: any;
  20006. /**
  20007. * Specifies if the ready state should be checked on each call
  20008. */
  20009. checkReadyOnEveryCall: boolean;
  20010. /**
  20011. * Specifies if the ready state should be checked once
  20012. */
  20013. checkReadyOnlyOnce: boolean;
  20014. /**
  20015. * The state of the material
  20016. */
  20017. state: string;
  20018. /**
  20019. * The alpha value of the material
  20020. */
  20021. protected _alpha: number;
  20022. /**
  20023. * List of inspectable custom properties (used by the Inspector)
  20024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20025. */
  20026. inspectableCustomProperties: IInspectable[];
  20027. /**
  20028. * Sets the alpha value of the material
  20029. */
  20030. /**
  20031. * Gets the alpha value of the material
  20032. */
  20033. alpha: number;
  20034. /**
  20035. * Specifies if back face culling is enabled
  20036. */
  20037. protected _backFaceCulling: boolean;
  20038. /**
  20039. * Sets the back-face culling state
  20040. */
  20041. /**
  20042. * Gets the back-face culling state
  20043. */
  20044. backFaceCulling: boolean;
  20045. /**
  20046. * Stores the value for side orientation
  20047. */
  20048. sideOrientation: number;
  20049. /**
  20050. * Callback triggered when the material is compiled
  20051. */
  20052. onCompiled: Nullable<(effect: Effect) => void>;
  20053. /**
  20054. * Callback triggered when an error occurs
  20055. */
  20056. onError: Nullable<(effect: Effect, errors: string) => void>;
  20057. /**
  20058. * Callback triggered to get the render target textures
  20059. */
  20060. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20061. /**
  20062. * Gets a boolean indicating that current material needs to register RTT
  20063. */
  20064. readonly hasRenderTargetTextures: boolean;
  20065. /**
  20066. * Specifies if the material should be serialized
  20067. */
  20068. doNotSerialize: boolean;
  20069. /**
  20070. * @hidden
  20071. */
  20072. _storeEffectOnSubMeshes: boolean;
  20073. /**
  20074. * Stores the animations for the material
  20075. */
  20076. animations: Nullable<Array<Animation>>;
  20077. /**
  20078. * An event triggered when the material is disposed
  20079. */
  20080. onDisposeObservable: Observable<Material>;
  20081. /**
  20082. * An observer which watches for dispose events
  20083. */
  20084. private _onDisposeObserver;
  20085. private _onUnBindObservable;
  20086. /**
  20087. * Called during a dispose event
  20088. */
  20089. onDispose: () => void;
  20090. private _onBindObservable;
  20091. /**
  20092. * An event triggered when the material is bound
  20093. */
  20094. readonly onBindObservable: Observable<AbstractMesh>;
  20095. /**
  20096. * An observer which watches for bind events
  20097. */
  20098. private _onBindObserver;
  20099. /**
  20100. * Called during a bind event
  20101. */
  20102. onBind: (Mesh: AbstractMesh) => void;
  20103. /**
  20104. * An event triggered when the material is unbound
  20105. */
  20106. readonly onUnBindObservable: Observable<Material>;
  20107. /**
  20108. * Stores the value of the alpha mode
  20109. */
  20110. private _alphaMode;
  20111. /**
  20112. * Sets the value of the alpha mode.
  20113. *
  20114. * | Value | Type | Description |
  20115. * | --- | --- | --- |
  20116. * | 0 | ALPHA_DISABLE | |
  20117. * | 1 | ALPHA_ADD | |
  20118. * | 2 | ALPHA_COMBINE | |
  20119. * | 3 | ALPHA_SUBTRACT | |
  20120. * | 4 | ALPHA_MULTIPLY | |
  20121. * | 5 | ALPHA_MAXIMIZED | |
  20122. * | 6 | ALPHA_ONEONE | |
  20123. * | 7 | ALPHA_PREMULTIPLIED | |
  20124. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20125. * | 9 | ALPHA_INTERPOLATE | |
  20126. * | 10 | ALPHA_SCREENMODE | |
  20127. *
  20128. */
  20129. /**
  20130. * Gets the value of the alpha mode
  20131. */
  20132. alphaMode: number;
  20133. /**
  20134. * Stores the state of the need depth pre-pass value
  20135. */
  20136. private _needDepthPrePass;
  20137. /**
  20138. * Sets the need depth pre-pass value
  20139. */
  20140. /**
  20141. * Gets the depth pre-pass value
  20142. */
  20143. needDepthPrePass: boolean;
  20144. /**
  20145. * Specifies if depth writing should be disabled
  20146. */
  20147. disableDepthWrite: boolean;
  20148. /**
  20149. * Specifies if depth writing should be forced
  20150. */
  20151. forceDepthWrite: boolean;
  20152. /**
  20153. * Specifies if there should be a separate pass for culling
  20154. */
  20155. separateCullingPass: boolean;
  20156. /**
  20157. * Stores the state specifing if fog should be enabled
  20158. */
  20159. private _fogEnabled;
  20160. /**
  20161. * Sets the state for enabling fog
  20162. */
  20163. /**
  20164. * Gets the value of the fog enabled state
  20165. */
  20166. fogEnabled: boolean;
  20167. /**
  20168. * Stores the size of points
  20169. */
  20170. pointSize: number;
  20171. /**
  20172. * Stores the z offset value
  20173. */
  20174. zOffset: number;
  20175. /**
  20176. * Gets a value specifying if wireframe mode is enabled
  20177. */
  20178. /**
  20179. * Sets the state of wireframe mode
  20180. */
  20181. wireframe: boolean;
  20182. /**
  20183. * Gets the value specifying if point clouds are enabled
  20184. */
  20185. /**
  20186. * Sets the state of point cloud mode
  20187. */
  20188. pointsCloud: boolean;
  20189. /**
  20190. * Gets the material fill mode
  20191. */
  20192. /**
  20193. * Sets the material fill mode
  20194. */
  20195. fillMode: number;
  20196. /**
  20197. * @hidden
  20198. * Stores the effects for the material
  20199. */
  20200. _effect: Nullable<Effect>;
  20201. /**
  20202. * @hidden
  20203. * Specifies if the material was previously ready
  20204. */
  20205. _wasPreviouslyReady: boolean;
  20206. /**
  20207. * Specifies if uniform buffers should be used
  20208. */
  20209. private _useUBO;
  20210. /**
  20211. * Stores a reference to the scene
  20212. */
  20213. private _scene;
  20214. /**
  20215. * Stores the fill mode state
  20216. */
  20217. private _fillMode;
  20218. /**
  20219. * Specifies if the depth write state should be cached
  20220. */
  20221. private _cachedDepthWriteState;
  20222. /**
  20223. * Stores the uniform buffer
  20224. */
  20225. protected _uniformBuffer: UniformBuffer;
  20226. /** @hidden */
  20227. _indexInSceneMaterialArray: number;
  20228. /** @hidden */
  20229. meshMap: Nullable<{
  20230. [id: string]: AbstractMesh | undefined;
  20231. }>;
  20232. /**
  20233. * Creates a material instance
  20234. * @param name defines the name of the material
  20235. * @param scene defines the scene to reference
  20236. * @param doNotAdd specifies if the material should be added to the scene
  20237. */
  20238. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20239. /**
  20240. * Returns a string representation of the current material
  20241. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20242. * @returns a string with material information
  20243. */
  20244. toString(fullDetails?: boolean): string;
  20245. /**
  20246. * Gets the class name of the material
  20247. * @returns a string with the class name of the material
  20248. */
  20249. getClassName(): string;
  20250. /**
  20251. * Specifies if updates for the material been locked
  20252. */
  20253. readonly isFrozen: boolean;
  20254. /**
  20255. * Locks updates for the material
  20256. */
  20257. freeze(): void;
  20258. /**
  20259. * Unlocks updates for the material
  20260. */
  20261. unfreeze(): void;
  20262. /**
  20263. * Specifies if the material is ready to be used
  20264. * @param mesh defines the mesh to check
  20265. * @param useInstances specifies if instances should be used
  20266. * @returns a boolean indicating if the material is ready to be used
  20267. */
  20268. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20269. /**
  20270. * Specifies that the submesh is ready to be used
  20271. * @param mesh defines the mesh to check
  20272. * @param subMesh defines which submesh to check
  20273. * @param useInstances specifies that instances should be used
  20274. * @returns a boolean indicating that the submesh is ready or not
  20275. */
  20276. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20277. /**
  20278. * Returns the material effect
  20279. * @returns the effect associated with the material
  20280. */
  20281. getEffect(): Nullable<Effect>;
  20282. /**
  20283. * Returns the current scene
  20284. * @returns a Scene
  20285. */
  20286. getScene(): Scene;
  20287. /**
  20288. * Specifies if the material will require alpha blending
  20289. * @returns a boolean specifying if alpha blending is needed
  20290. */
  20291. needAlphaBlending(): boolean;
  20292. /**
  20293. * Specifies if the mesh will require alpha blending
  20294. * @param mesh defines the mesh to check
  20295. * @returns a boolean specifying if alpha blending is needed for the mesh
  20296. */
  20297. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20298. /**
  20299. * Specifies if this material should be rendered in alpha test mode
  20300. * @returns a boolean specifying if an alpha test is needed.
  20301. */
  20302. needAlphaTesting(): boolean;
  20303. /**
  20304. * Gets the texture used for the alpha test
  20305. * @returns the texture to use for alpha testing
  20306. */
  20307. getAlphaTestTexture(): Nullable<BaseTexture>;
  20308. /**
  20309. * Marks the material to indicate that it needs to be re-calculated
  20310. */
  20311. markDirty(): void;
  20312. /** @hidden */
  20313. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20314. /**
  20315. * Binds the material to the mesh
  20316. * @param world defines the world transformation matrix
  20317. * @param mesh defines the mesh to bind the material to
  20318. */
  20319. bind(world: Matrix, mesh?: Mesh): void;
  20320. /**
  20321. * Binds the submesh to the material
  20322. * @param world defines the world transformation matrix
  20323. * @param mesh defines the mesh containing the submesh
  20324. * @param subMesh defines the submesh to bind the material to
  20325. */
  20326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20327. /**
  20328. * Binds the world matrix to the material
  20329. * @param world defines the world transformation matrix
  20330. */
  20331. bindOnlyWorldMatrix(world: Matrix): void;
  20332. /**
  20333. * Binds the scene's uniform buffer to the effect.
  20334. * @param effect defines the effect to bind to the scene uniform buffer
  20335. * @param sceneUbo defines the uniform buffer storing scene data
  20336. */
  20337. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20338. /**
  20339. * Binds the view matrix to the effect
  20340. * @param effect defines the effect to bind the view matrix to
  20341. */
  20342. bindView(effect: Effect): void;
  20343. /**
  20344. * Binds the view projection matrix to the effect
  20345. * @param effect defines the effect to bind the view projection matrix to
  20346. */
  20347. bindViewProjection(effect: Effect): void;
  20348. /**
  20349. * Specifies if material alpha testing should be turned on for the mesh
  20350. * @param mesh defines the mesh to check
  20351. */
  20352. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20353. /**
  20354. * Processes to execute after binding the material to a mesh
  20355. * @param mesh defines the rendered mesh
  20356. */
  20357. protected _afterBind(mesh?: Mesh): void;
  20358. /**
  20359. * Unbinds the material from the mesh
  20360. */
  20361. unbind(): void;
  20362. /**
  20363. * Gets the active textures from the material
  20364. * @returns an array of textures
  20365. */
  20366. getActiveTextures(): BaseTexture[];
  20367. /**
  20368. * Specifies if the material uses a texture
  20369. * @param texture defines the texture to check against the material
  20370. * @returns a boolean specifying if the material uses the texture
  20371. */
  20372. hasTexture(texture: BaseTexture): boolean;
  20373. /**
  20374. * Makes a duplicate of the material, and gives it a new name
  20375. * @param name defines the new name for the duplicated material
  20376. * @returns the cloned material
  20377. */
  20378. clone(name: string): Nullable<Material>;
  20379. /**
  20380. * Gets the meshes bound to the material
  20381. * @returns an array of meshes bound to the material
  20382. */
  20383. getBindedMeshes(): AbstractMesh[];
  20384. /**
  20385. * Force shader compilation
  20386. * @param mesh defines the mesh associated with this material
  20387. * @param onCompiled defines a function to execute once the material is compiled
  20388. * @param options defines the options to configure the compilation
  20389. */
  20390. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20391. clipPlane: boolean;
  20392. }>): void;
  20393. /**
  20394. * Force shader compilation
  20395. * @param mesh defines the mesh that will use this material
  20396. * @param options defines additional options for compiling the shaders
  20397. * @returns a promise that resolves when the compilation completes
  20398. */
  20399. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20400. clipPlane: boolean;
  20401. }>): Promise<void>;
  20402. private static readonly _AllDirtyCallBack;
  20403. private static readonly _ImageProcessingDirtyCallBack;
  20404. private static readonly _TextureDirtyCallBack;
  20405. private static readonly _FresnelDirtyCallBack;
  20406. private static readonly _MiscDirtyCallBack;
  20407. private static readonly _LightsDirtyCallBack;
  20408. private static readonly _AttributeDirtyCallBack;
  20409. private static _FresnelAndMiscDirtyCallBack;
  20410. private static _TextureAndMiscDirtyCallBack;
  20411. private static readonly _DirtyCallbackArray;
  20412. private static readonly _RunDirtyCallBacks;
  20413. /**
  20414. * Marks a define in the material to indicate that it needs to be re-computed
  20415. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20416. */
  20417. markAsDirty(flag: number): void;
  20418. /**
  20419. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20420. * @param func defines a function which checks material defines against the submeshes
  20421. */
  20422. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20423. /**
  20424. * Indicates that we need to re-calculated for all submeshes
  20425. */
  20426. protected _markAllSubMeshesAsAllDirty(): void;
  20427. /**
  20428. * Indicates that image processing needs to be re-calculated for all submeshes
  20429. */
  20430. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20431. /**
  20432. * Indicates that textures need to be re-calculated for all submeshes
  20433. */
  20434. protected _markAllSubMeshesAsTexturesDirty(): void;
  20435. /**
  20436. * Indicates that fresnel needs to be re-calculated for all submeshes
  20437. */
  20438. protected _markAllSubMeshesAsFresnelDirty(): void;
  20439. /**
  20440. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20441. */
  20442. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20443. /**
  20444. * Indicates that lights need to be re-calculated for all submeshes
  20445. */
  20446. protected _markAllSubMeshesAsLightsDirty(): void;
  20447. /**
  20448. * Indicates that attributes need to be re-calculated for all submeshes
  20449. */
  20450. protected _markAllSubMeshesAsAttributesDirty(): void;
  20451. /**
  20452. * Indicates that misc needs to be re-calculated for all submeshes
  20453. */
  20454. protected _markAllSubMeshesAsMiscDirty(): void;
  20455. /**
  20456. * Indicates that textures and misc need to be re-calculated for all submeshes
  20457. */
  20458. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20459. /**
  20460. * Disposes the material
  20461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20464. */
  20465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20466. /** @hidden */
  20467. private releaseVertexArrayObject;
  20468. /**
  20469. * Serializes this material
  20470. * @returns the serialized material object
  20471. */
  20472. serialize(): any;
  20473. /**
  20474. * Creates a material from parsed material data
  20475. * @param parsedMaterial defines parsed material data
  20476. * @param scene defines the hosting scene
  20477. * @param rootUrl defines the root URL to use to load textures
  20478. * @returns a new material
  20479. */
  20480. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20481. }
  20482. }
  20483. declare module BABYLON {
  20484. /**
  20485. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20486. * separate meshes. This can be use to improve performances.
  20487. * @see http://doc.babylonjs.com/how_to/multi_materials
  20488. */
  20489. export class MultiMaterial extends Material {
  20490. private _subMaterials;
  20491. /**
  20492. * Gets or Sets the list of Materials used within the multi material.
  20493. * They need to be ordered according to the submeshes order in the associated mesh
  20494. */
  20495. subMaterials: Nullable<Material>[];
  20496. /**
  20497. * Function used to align with Node.getChildren()
  20498. * @returns the list of Materials used within the multi material
  20499. */
  20500. getChildren(): Nullable<Material>[];
  20501. /**
  20502. * Instantiates a new Multi Material
  20503. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20504. * separate meshes. This can be use to improve performances.
  20505. * @see http://doc.babylonjs.com/how_to/multi_materials
  20506. * @param name Define the name in the scene
  20507. * @param scene Define the scene the material belongs to
  20508. */
  20509. constructor(name: string, scene: Scene);
  20510. private _hookArray;
  20511. /**
  20512. * Get one of the submaterial by its index in the submaterials array
  20513. * @param index The index to look the sub material at
  20514. * @returns The Material if the index has been defined
  20515. */
  20516. getSubMaterial(index: number): Nullable<Material>;
  20517. /**
  20518. * Get the list of active textures for the whole sub materials list.
  20519. * @returns All the textures that will be used during the rendering
  20520. */
  20521. getActiveTextures(): BaseTexture[];
  20522. /**
  20523. * Gets the current class name of the material e.g. "MultiMaterial"
  20524. * Mainly use in serialization.
  20525. * @returns the class name
  20526. */
  20527. getClassName(): string;
  20528. /**
  20529. * Checks if the material is ready to render the requested sub mesh
  20530. * @param mesh Define the mesh the submesh belongs to
  20531. * @param subMesh Define the sub mesh to look readyness for
  20532. * @param useInstances Define whether or not the material is used with instances
  20533. * @returns true if ready, otherwise false
  20534. */
  20535. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20536. /**
  20537. * Clones the current material and its related sub materials
  20538. * @param name Define the name of the newly cloned material
  20539. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20540. * @returns the cloned material
  20541. */
  20542. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20543. /**
  20544. * Serializes the materials into a JSON representation.
  20545. * @returns the JSON representation
  20546. */
  20547. serialize(): any;
  20548. /**
  20549. * Dispose the material and release its associated resources
  20550. * @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)
  20551. * @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)
  20552. * @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)
  20553. */
  20554. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20555. /**
  20556. * Creates a MultiMaterial from parsed MultiMaterial data.
  20557. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20558. * @param scene defines the hosting scene
  20559. * @returns a new MultiMaterial
  20560. */
  20561. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20562. }
  20563. }
  20564. declare module BABYLON {
  20565. /**
  20566. * Base class for submeshes
  20567. */
  20568. export class BaseSubMesh {
  20569. /** @hidden */
  20570. _materialDefines: Nullable<MaterialDefines>;
  20571. /** @hidden */
  20572. _materialEffect: Nullable<Effect>;
  20573. /**
  20574. * Gets associated effect
  20575. */
  20576. readonly effect: Nullable<Effect>;
  20577. /**
  20578. * Sets associated effect (effect used to render this submesh)
  20579. * @param effect defines the effect to associate with
  20580. * @param defines defines the set of defines used to compile this effect
  20581. */
  20582. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20583. }
  20584. /**
  20585. * Defines a subdivision inside a mesh
  20586. */
  20587. export class SubMesh extends BaseSubMesh implements ICullable {
  20588. /** the material index to use */
  20589. materialIndex: number;
  20590. /** vertex index start */
  20591. verticesStart: number;
  20592. /** vertices count */
  20593. verticesCount: number;
  20594. /** index start */
  20595. indexStart: number;
  20596. /** indices count */
  20597. indexCount: number;
  20598. /** @hidden */
  20599. _linesIndexCount: number;
  20600. private _mesh;
  20601. private _renderingMesh;
  20602. private _boundingInfo;
  20603. private _linesIndexBuffer;
  20604. /** @hidden */
  20605. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20606. /** @hidden */
  20607. _trianglePlanes: Plane[];
  20608. /** @hidden */
  20609. _lastColliderTransformMatrix: Nullable<Matrix>;
  20610. /** @hidden */
  20611. _renderId: number;
  20612. /** @hidden */
  20613. _alphaIndex: number;
  20614. /** @hidden */
  20615. _distanceToCamera: number;
  20616. /** @hidden */
  20617. _id: number;
  20618. private _currentMaterial;
  20619. /**
  20620. * Add a new submesh to a mesh
  20621. * @param materialIndex defines the material index to use
  20622. * @param verticesStart defines vertex index start
  20623. * @param verticesCount defines vertices count
  20624. * @param indexStart defines index start
  20625. * @param indexCount defines indices count
  20626. * @param mesh defines the parent mesh
  20627. * @param renderingMesh defines an optional rendering mesh
  20628. * @param createBoundingBox defines if bounding box should be created for this submesh
  20629. * @returns the new submesh
  20630. */
  20631. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20632. /**
  20633. * Creates a new submesh
  20634. * @param materialIndex defines the material index to use
  20635. * @param verticesStart defines vertex index start
  20636. * @param verticesCount defines vertices count
  20637. * @param indexStart defines index start
  20638. * @param indexCount defines indices count
  20639. * @param mesh defines the parent mesh
  20640. * @param renderingMesh defines an optional rendering mesh
  20641. * @param createBoundingBox defines if bounding box should be created for this submesh
  20642. */
  20643. constructor(
  20644. /** the material index to use */
  20645. materialIndex: number,
  20646. /** vertex index start */
  20647. verticesStart: number,
  20648. /** vertices count */
  20649. verticesCount: number,
  20650. /** index start */
  20651. indexStart: number,
  20652. /** indices count */
  20653. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20654. /**
  20655. * Returns true if this submesh covers the entire parent mesh
  20656. * @ignorenaming
  20657. */
  20658. readonly IsGlobal: boolean;
  20659. /**
  20660. * Returns the submesh BoudingInfo object
  20661. * @returns current bounding info (or mesh's one if the submesh is global)
  20662. */
  20663. getBoundingInfo(): BoundingInfo;
  20664. /**
  20665. * Sets the submesh BoundingInfo
  20666. * @param boundingInfo defines the new bounding info to use
  20667. * @returns the SubMesh
  20668. */
  20669. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20670. /**
  20671. * Returns the mesh of the current submesh
  20672. * @return the parent mesh
  20673. */
  20674. getMesh(): AbstractMesh;
  20675. /**
  20676. * Returns the rendering mesh of the submesh
  20677. * @returns the rendering mesh (could be different from parent mesh)
  20678. */
  20679. getRenderingMesh(): Mesh;
  20680. /**
  20681. * Returns the submesh material
  20682. * @returns null or the current material
  20683. */
  20684. getMaterial(): Nullable<Material>;
  20685. /**
  20686. * Sets a new updated BoundingInfo object to the submesh
  20687. * @param data defines an optional position array to use to determine the bounding info
  20688. * @returns the SubMesh
  20689. */
  20690. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20691. /** @hidden */
  20692. _checkCollision(collider: Collider): boolean;
  20693. /**
  20694. * Updates the submesh BoundingInfo
  20695. * @param world defines the world matrix to use to update the bounding info
  20696. * @returns the submesh
  20697. */
  20698. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20699. /**
  20700. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20701. * @param frustumPlanes defines the frustum planes
  20702. * @returns true if the submesh is intersecting with the frustum
  20703. */
  20704. isInFrustum(frustumPlanes: Plane[]): boolean;
  20705. /**
  20706. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20707. * @param frustumPlanes defines the frustum planes
  20708. * @returns true if the submesh is inside the frustum
  20709. */
  20710. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20711. /**
  20712. * Renders the submesh
  20713. * @param enableAlphaMode defines if alpha needs to be used
  20714. * @returns the submesh
  20715. */
  20716. render(enableAlphaMode: boolean): SubMesh;
  20717. /**
  20718. * @hidden
  20719. */
  20720. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20721. /**
  20722. * Checks if the submesh intersects with a ray
  20723. * @param ray defines the ray to test
  20724. * @returns true is the passed ray intersects the submesh bounding box
  20725. */
  20726. canIntersects(ray: Ray): boolean;
  20727. /**
  20728. * Intersects current submesh with a ray
  20729. * @param ray defines the ray to test
  20730. * @param positions defines mesh's positions array
  20731. * @param indices defines mesh's indices array
  20732. * @param fastCheck defines if only bounding info should be used
  20733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20734. * @returns intersection info or null if no intersection
  20735. */
  20736. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20737. /** @hidden */
  20738. private _intersectLines;
  20739. /** @hidden */
  20740. private _intersectUnIndexedLines;
  20741. /** @hidden */
  20742. private _intersectTriangles;
  20743. /** @hidden */
  20744. private _intersectUnIndexedTriangles;
  20745. /** @hidden */
  20746. _rebuild(): void;
  20747. /**
  20748. * Creates a new submesh from the passed mesh
  20749. * @param newMesh defines the new hosting mesh
  20750. * @param newRenderingMesh defines an optional rendering mesh
  20751. * @returns the new submesh
  20752. */
  20753. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20754. /**
  20755. * Release associated resources
  20756. */
  20757. dispose(): void;
  20758. /**
  20759. * Gets the class name
  20760. * @returns the string "SubMesh".
  20761. */
  20762. getClassName(): string;
  20763. /**
  20764. * Creates a new submesh from indices data
  20765. * @param materialIndex the index of the main mesh material
  20766. * @param startIndex the index where to start the copy in the mesh indices array
  20767. * @param indexCount the number of indices to copy then from the startIndex
  20768. * @param mesh the main mesh to create the submesh from
  20769. * @param renderingMesh the optional rendering mesh
  20770. * @returns a new submesh
  20771. */
  20772. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20773. }
  20774. }
  20775. declare module BABYLON {
  20776. /**
  20777. * Class used to represent data loading progression
  20778. */
  20779. export class SceneLoaderFlags {
  20780. private static _ForceFullSceneLoadingForIncremental;
  20781. private static _ShowLoadingScreen;
  20782. private static _CleanBoneMatrixWeights;
  20783. private static _loggingLevel;
  20784. /**
  20785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20786. */
  20787. static ForceFullSceneLoadingForIncremental: boolean;
  20788. /**
  20789. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20790. */
  20791. static ShowLoadingScreen: boolean;
  20792. /**
  20793. * Defines the current logging level (while loading the scene)
  20794. * @ignorenaming
  20795. */
  20796. static loggingLevel: number;
  20797. /**
  20798. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20799. */
  20800. static CleanBoneMatrixWeights: boolean;
  20801. }
  20802. }
  20803. declare module BABYLON {
  20804. /**
  20805. * Class used to store geometry data (vertex buffers + index buffer)
  20806. */
  20807. export class Geometry implements IGetSetVerticesData {
  20808. /**
  20809. * Gets or sets the ID of the geometry
  20810. */
  20811. id: string;
  20812. /**
  20813. * Gets or sets the unique ID of the geometry
  20814. */
  20815. uniqueId: number;
  20816. /**
  20817. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20818. */
  20819. delayLoadState: number;
  20820. /**
  20821. * Gets the file containing the data to load when running in delay load state
  20822. */
  20823. delayLoadingFile: Nullable<string>;
  20824. /**
  20825. * Callback called when the geometry is updated
  20826. */
  20827. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20828. private _scene;
  20829. private _engine;
  20830. private _meshes;
  20831. private _totalVertices;
  20832. /** @hidden */
  20833. _indices: IndicesArray;
  20834. /** @hidden */
  20835. _vertexBuffers: {
  20836. [key: string]: VertexBuffer;
  20837. };
  20838. private _isDisposed;
  20839. private _extend;
  20840. private _boundingBias;
  20841. /** @hidden */
  20842. _delayInfo: Array<string>;
  20843. private _indexBuffer;
  20844. private _indexBufferIsUpdatable;
  20845. /** @hidden */
  20846. _boundingInfo: Nullable<BoundingInfo>;
  20847. /** @hidden */
  20848. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20849. /** @hidden */
  20850. _softwareSkinningFrameId: number;
  20851. private _vertexArrayObjects;
  20852. private _updatable;
  20853. /** @hidden */
  20854. _positions: Nullable<Vector3[]>;
  20855. /**
  20856. * 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
  20857. */
  20858. /**
  20859. * 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
  20860. */
  20861. boundingBias: Vector2;
  20862. /**
  20863. * Static function used to attach a new empty geometry to a mesh
  20864. * @param mesh defines the mesh to attach the geometry to
  20865. * @returns the new Geometry
  20866. */
  20867. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20868. /**
  20869. * Creates a new geometry
  20870. * @param id defines the unique ID
  20871. * @param scene defines the hosting scene
  20872. * @param vertexData defines the VertexData used to get geometry data
  20873. * @param updatable defines if geometry must be updatable (false by default)
  20874. * @param mesh defines the mesh that will be associated with the geometry
  20875. */
  20876. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20877. /**
  20878. * Gets the current extend of the geometry
  20879. */
  20880. readonly extend: {
  20881. minimum: Vector3;
  20882. maximum: Vector3;
  20883. };
  20884. /**
  20885. * Gets the hosting scene
  20886. * @returns the hosting Scene
  20887. */
  20888. getScene(): Scene;
  20889. /**
  20890. * Gets the hosting engine
  20891. * @returns the hosting Engine
  20892. */
  20893. getEngine(): Engine;
  20894. /**
  20895. * Defines if the geometry is ready to use
  20896. * @returns true if the geometry is ready to be used
  20897. */
  20898. isReady(): boolean;
  20899. /**
  20900. * Gets a value indicating that the geometry should not be serialized
  20901. */
  20902. readonly doNotSerialize: boolean;
  20903. /** @hidden */
  20904. _rebuild(): void;
  20905. /**
  20906. * Affects all geometry data in one call
  20907. * @param vertexData defines the geometry data
  20908. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20909. */
  20910. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20911. /**
  20912. * Set specific vertex data
  20913. * @param kind defines the data kind (Position, normal, etc...)
  20914. * @param data defines the vertex data to use
  20915. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20916. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20917. */
  20918. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20919. /**
  20920. * Removes a specific vertex data
  20921. * @param kind defines the data kind (Position, normal, etc...)
  20922. */
  20923. removeVerticesData(kind: string): void;
  20924. /**
  20925. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20926. * @param buffer defines the vertex buffer to use
  20927. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20928. */
  20929. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20930. /**
  20931. * Update a specific vertex buffer
  20932. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20933. * It will do nothing if the buffer is not updatable
  20934. * @param kind defines the data kind (Position, normal, etc...)
  20935. * @param data defines the data to use
  20936. * @param offset defines the offset in the target buffer where to store the data
  20937. * @param useBytes set to true if the offset is in bytes
  20938. */
  20939. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20940. /**
  20941. * Update a specific vertex buffer
  20942. * This function will create a new buffer if the current one is not updatable
  20943. * @param kind defines the data kind (Position, normal, etc...)
  20944. * @param data defines the data to use
  20945. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20946. */
  20947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20948. private _updateBoundingInfo;
  20949. /** @hidden */
  20950. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20951. /**
  20952. * Gets total number of vertices
  20953. * @returns the total number of vertices
  20954. */
  20955. getTotalVertices(): number;
  20956. /**
  20957. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20958. * @param kind defines the data kind (Position, normal, etc...)
  20959. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20960. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20961. * @returns a float array containing vertex data
  20962. */
  20963. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20964. /**
  20965. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20966. * @param kind defines the data kind (Position, normal, etc...)
  20967. * @returns true if the vertex buffer with the specified kind is updatable
  20968. */
  20969. isVertexBufferUpdatable(kind: string): boolean;
  20970. /**
  20971. * Gets a specific vertex buffer
  20972. * @param kind defines the data kind (Position, normal, etc...)
  20973. * @returns a VertexBuffer
  20974. */
  20975. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20976. /**
  20977. * Returns all vertex buffers
  20978. * @return an object holding all vertex buffers indexed by kind
  20979. */
  20980. getVertexBuffers(): Nullable<{
  20981. [key: string]: VertexBuffer;
  20982. }>;
  20983. /**
  20984. * Gets a boolean indicating if specific vertex buffer is present
  20985. * @param kind defines the data kind (Position, normal, etc...)
  20986. * @returns true if data is present
  20987. */
  20988. isVerticesDataPresent(kind: string): boolean;
  20989. /**
  20990. * Gets a list of all attached data kinds (Position, normal, etc...)
  20991. * @returns a list of string containing all kinds
  20992. */
  20993. getVerticesDataKinds(): string[];
  20994. /**
  20995. * Update index buffer
  20996. * @param indices defines the indices to store in the index buffer
  20997. * @param offset defines the offset in the target buffer where to store the data
  20998. * @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)
  20999. */
  21000. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21001. /**
  21002. * Creates a new index buffer
  21003. * @param indices defines the indices to store in the index buffer
  21004. * @param totalVertices defines the total number of vertices (could be null)
  21005. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21006. */
  21007. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21008. /**
  21009. * Return the total number of indices
  21010. * @returns the total number of indices
  21011. */
  21012. getTotalIndices(): number;
  21013. /**
  21014. * Gets the index buffer array
  21015. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21017. * @returns the index buffer array
  21018. */
  21019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21020. /**
  21021. * Gets the index buffer
  21022. * @return the index buffer
  21023. */
  21024. getIndexBuffer(): Nullable<DataBuffer>;
  21025. /** @hidden */
  21026. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21027. /**
  21028. * Release the associated resources for a specific mesh
  21029. * @param mesh defines the source mesh
  21030. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21031. */
  21032. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21033. /**
  21034. * Apply current geometry to a given mesh
  21035. * @param mesh defines the mesh to apply geometry to
  21036. */
  21037. applyToMesh(mesh: Mesh): void;
  21038. private _updateExtend;
  21039. private _applyToMesh;
  21040. private notifyUpdate;
  21041. /**
  21042. * Load the geometry if it was flagged as delay loaded
  21043. * @param scene defines the hosting scene
  21044. * @param onLoaded defines a callback called when the geometry is loaded
  21045. */
  21046. load(scene: Scene, onLoaded?: () => void): void;
  21047. private _queueLoad;
  21048. /**
  21049. * Invert the geometry to move from a right handed system to a left handed one.
  21050. */
  21051. toLeftHanded(): void;
  21052. /** @hidden */
  21053. _resetPointsArrayCache(): void;
  21054. /** @hidden */
  21055. _generatePointsArray(): boolean;
  21056. /**
  21057. * Gets a value indicating if the geometry is disposed
  21058. * @returns true if the geometry was disposed
  21059. */
  21060. isDisposed(): boolean;
  21061. private _disposeVertexArrayObjects;
  21062. /**
  21063. * Free all associated resources
  21064. */
  21065. dispose(): void;
  21066. /**
  21067. * Clone the current geometry into a new geometry
  21068. * @param id defines the unique ID of the new geometry
  21069. * @returns a new geometry object
  21070. */
  21071. copy(id: string): Geometry;
  21072. /**
  21073. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21074. * @return a JSON representation of the current geometry data (without the vertices data)
  21075. */
  21076. serialize(): any;
  21077. private toNumberArray;
  21078. /**
  21079. * Serialize all vertices data into a JSON oject
  21080. * @returns a JSON representation of the current geometry data
  21081. */
  21082. serializeVerticeData(): any;
  21083. /**
  21084. * Extracts a clone of a mesh geometry
  21085. * @param mesh defines the source mesh
  21086. * @param id defines the unique ID of the new geometry object
  21087. * @returns the new geometry object
  21088. */
  21089. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21090. /**
  21091. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21092. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21093. * Be aware Math.random() could cause collisions, but:
  21094. * "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"
  21095. * @returns a string containing a new GUID
  21096. */
  21097. static RandomId(): string;
  21098. /** @hidden */
  21099. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21100. private static _CleanMatricesWeights;
  21101. /**
  21102. * Create a new geometry from persisted data (Using .babylon file format)
  21103. * @param parsedVertexData defines the persisted data
  21104. * @param scene defines the hosting scene
  21105. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21106. * @returns the new geometry object
  21107. */
  21108. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21109. }
  21110. }
  21111. declare module BABYLON {
  21112. /**
  21113. * Define an interface for all classes that will get and set the data on vertices
  21114. */
  21115. export interface IGetSetVerticesData {
  21116. /**
  21117. * Gets a boolean indicating if specific vertex data is present
  21118. * @param kind defines the vertex data kind to use
  21119. * @returns true is data kind is present
  21120. */
  21121. isVerticesDataPresent(kind: string): boolean;
  21122. /**
  21123. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21124. * @param kind defines the data kind (Position, normal, etc...)
  21125. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21127. * @returns a float array containing vertex data
  21128. */
  21129. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21130. /**
  21131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21132. * @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.
  21133. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21134. * @returns the indices array or an empty array if the mesh has no geometry
  21135. */
  21136. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21137. /**
  21138. * Set specific vertex data
  21139. * @param kind defines the data kind (Position, normal, etc...)
  21140. * @param data defines the vertex data to use
  21141. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21142. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21143. */
  21144. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21145. /**
  21146. * Update a specific associated vertex buffer
  21147. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21148. * - VertexBuffer.PositionKind
  21149. * - VertexBuffer.UVKind
  21150. * - VertexBuffer.UV2Kind
  21151. * - VertexBuffer.UV3Kind
  21152. * - VertexBuffer.UV4Kind
  21153. * - VertexBuffer.UV5Kind
  21154. * - VertexBuffer.UV6Kind
  21155. * - VertexBuffer.ColorKind
  21156. * - VertexBuffer.MatricesIndicesKind
  21157. * - VertexBuffer.MatricesIndicesExtraKind
  21158. * - VertexBuffer.MatricesWeightsKind
  21159. * - VertexBuffer.MatricesWeightsExtraKind
  21160. * @param data defines the data source
  21161. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21162. * @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)
  21163. */
  21164. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21165. /**
  21166. * Creates a new index buffer
  21167. * @param indices defines the indices to store in the index buffer
  21168. * @param totalVertices defines the total number of vertices (could be null)
  21169. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21170. */
  21171. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21172. }
  21173. /**
  21174. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21175. */
  21176. export class VertexData {
  21177. /**
  21178. * Mesh side orientation : usually the external or front surface
  21179. */
  21180. static readonly FRONTSIDE: number;
  21181. /**
  21182. * Mesh side orientation : usually the internal or back surface
  21183. */
  21184. static readonly BACKSIDE: number;
  21185. /**
  21186. * Mesh side orientation : both internal and external or front and back surfaces
  21187. */
  21188. static readonly DOUBLESIDE: number;
  21189. /**
  21190. * Mesh side orientation : by default, `FRONTSIDE`
  21191. */
  21192. static readonly DEFAULTSIDE: number;
  21193. /**
  21194. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21195. */
  21196. positions: Nullable<FloatArray>;
  21197. /**
  21198. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21199. */
  21200. normals: Nullable<FloatArray>;
  21201. /**
  21202. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21203. */
  21204. tangents: Nullable<FloatArray>;
  21205. /**
  21206. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21207. */
  21208. uvs: Nullable<FloatArray>;
  21209. /**
  21210. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21211. */
  21212. uvs2: Nullable<FloatArray>;
  21213. /**
  21214. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21215. */
  21216. uvs3: Nullable<FloatArray>;
  21217. /**
  21218. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21219. */
  21220. uvs4: Nullable<FloatArray>;
  21221. /**
  21222. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21223. */
  21224. uvs5: Nullable<FloatArray>;
  21225. /**
  21226. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21227. */
  21228. uvs6: Nullable<FloatArray>;
  21229. /**
  21230. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21231. */
  21232. colors: Nullable<FloatArray>;
  21233. /**
  21234. * 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).
  21235. */
  21236. matricesIndices: Nullable<FloatArray>;
  21237. /**
  21238. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21239. */
  21240. matricesWeights: Nullable<FloatArray>;
  21241. /**
  21242. * An array extending the number of possible indices
  21243. */
  21244. matricesIndicesExtra: Nullable<FloatArray>;
  21245. /**
  21246. * An array extending the number of possible weights when the number of indices is extended
  21247. */
  21248. matricesWeightsExtra: Nullable<FloatArray>;
  21249. /**
  21250. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21251. */
  21252. indices: Nullable<IndicesArray>;
  21253. /**
  21254. * Uses the passed data array to set the set the values for the specified kind of data
  21255. * @param data a linear array of floating numbers
  21256. * @param kind the type of data that is being set, eg positions, colors etc
  21257. */
  21258. set(data: FloatArray, kind: string): void;
  21259. /**
  21260. * Associates the vertexData to the passed Mesh.
  21261. * Sets it as updatable or not (default `false`)
  21262. * @param mesh the mesh the vertexData is applied to
  21263. * @param updatable when used and having the value true allows new data to update the vertexData
  21264. * @returns the VertexData
  21265. */
  21266. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21267. /**
  21268. * Associates the vertexData to the passed Geometry.
  21269. * Sets it as updatable or not (default `false`)
  21270. * @param geometry the geometry the vertexData is applied to
  21271. * @param updatable when used and having the value true allows new data to update the vertexData
  21272. * @returns VertexData
  21273. */
  21274. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21275. /**
  21276. * Updates the associated mesh
  21277. * @param mesh the mesh to be updated
  21278. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21279. * @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
  21280. * @returns VertexData
  21281. */
  21282. updateMesh(mesh: Mesh): VertexData;
  21283. /**
  21284. * Updates the associated geometry
  21285. * @param geometry the geometry to be updated
  21286. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21287. * @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
  21288. * @returns VertexData.
  21289. */
  21290. updateGeometry(geometry: Geometry): VertexData;
  21291. private _applyTo;
  21292. private _update;
  21293. /**
  21294. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21295. * @param matrix the transforming matrix
  21296. * @returns the VertexData
  21297. */
  21298. transform(matrix: Matrix): VertexData;
  21299. /**
  21300. * Merges the passed VertexData into the current one
  21301. * @param other the VertexData to be merged into the current one
  21302. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21303. * @returns the modified VertexData
  21304. */
  21305. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21306. private _mergeElement;
  21307. private _validate;
  21308. /**
  21309. * Serializes the VertexData
  21310. * @returns a serialized object
  21311. */
  21312. serialize(): any;
  21313. /**
  21314. * Extracts the vertexData from a mesh
  21315. * @param mesh the mesh from which to extract the VertexData
  21316. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21317. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21318. * @returns the object VertexData associated to the passed mesh
  21319. */
  21320. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21321. /**
  21322. * Extracts the vertexData from the geometry
  21323. * @param geometry the geometry from which to extract the VertexData
  21324. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21325. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21326. * @returns the object VertexData associated to the passed mesh
  21327. */
  21328. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21329. private static _ExtractFrom;
  21330. /**
  21331. * Creates the VertexData for a Ribbon
  21332. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21333. * * pathArray array of paths, each of which an array of successive Vector3
  21334. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21335. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21336. * * 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
  21337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21338. * * 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)
  21339. * * 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)
  21340. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21341. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21342. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21343. * @returns the VertexData of the ribbon
  21344. */
  21345. static CreateRibbon(options: {
  21346. pathArray: Vector3[][];
  21347. closeArray?: boolean;
  21348. closePath?: boolean;
  21349. offset?: number;
  21350. sideOrientation?: number;
  21351. frontUVs?: Vector4;
  21352. backUVs?: Vector4;
  21353. invertUV?: boolean;
  21354. uvs?: Vector2[];
  21355. colors?: Color4[];
  21356. }): VertexData;
  21357. /**
  21358. * Creates the VertexData for a box
  21359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21360. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21361. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21362. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21363. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21364. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21365. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21367. * * 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)
  21368. * * 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)
  21369. * @returns the VertexData of the box
  21370. */
  21371. static CreateBox(options: {
  21372. size?: number;
  21373. width?: number;
  21374. height?: number;
  21375. depth?: number;
  21376. faceUV?: Vector4[];
  21377. faceColors?: Color4[];
  21378. sideOrientation?: number;
  21379. frontUVs?: Vector4;
  21380. backUVs?: Vector4;
  21381. }): VertexData;
  21382. /**
  21383. * Creates the VertexData for a tiled box
  21384. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21385. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21386. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21387. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21389. * @returns the VertexData of the box
  21390. */
  21391. static CreateTiledBox(options: {
  21392. pattern?: number;
  21393. width?: number;
  21394. height?: number;
  21395. depth?: number;
  21396. tileSize?: number;
  21397. tileWidth?: number;
  21398. tileHeight?: number;
  21399. alignHorizontal?: number;
  21400. alignVertical?: number;
  21401. faceUV?: Vector4[];
  21402. faceColors?: Color4[];
  21403. sideOrientation?: number;
  21404. }): VertexData;
  21405. /**
  21406. * Creates the VertexData for a tiled plane
  21407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21408. * * pattern a limited pattern arrangement depending on the number
  21409. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21410. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21411. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21412. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21413. * * 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)
  21414. * * 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)
  21415. * @returns the VertexData of the tiled plane
  21416. */
  21417. static CreateTiledPlane(options: {
  21418. pattern?: number;
  21419. tileSize?: number;
  21420. tileWidth?: number;
  21421. tileHeight?: number;
  21422. size?: number;
  21423. width?: number;
  21424. height?: number;
  21425. alignHorizontal?: number;
  21426. alignVertical?: number;
  21427. sideOrientation?: number;
  21428. frontUVs?: Vector4;
  21429. backUVs?: Vector4;
  21430. }): VertexData;
  21431. /**
  21432. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21434. * * segments sets the number of horizontal strips optional, default 32
  21435. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21436. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21437. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21438. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21439. * * 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
  21440. * * 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
  21441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21442. * * 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)
  21443. * * 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)
  21444. * @returns the VertexData of the ellipsoid
  21445. */
  21446. static CreateSphere(options: {
  21447. segments?: number;
  21448. diameter?: number;
  21449. diameterX?: number;
  21450. diameterY?: number;
  21451. diameterZ?: number;
  21452. arc?: number;
  21453. slice?: number;
  21454. sideOrientation?: number;
  21455. frontUVs?: Vector4;
  21456. backUVs?: Vector4;
  21457. }): VertexData;
  21458. /**
  21459. * Creates the VertexData for a cylinder, cone or prism
  21460. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21461. * * height sets the height (y direction) of the cylinder, optional, default 2
  21462. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21463. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21464. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21465. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21466. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21467. * * 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
  21468. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21469. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21470. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21471. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21473. * * 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)
  21474. * * 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)
  21475. * @returns the VertexData of the cylinder, cone or prism
  21476. */
  21477. static CreateCylinder(options: {
  21478. height?: number;
  21479. diameterTop?: number;
  21480. diameterBottom?: number;
  21481. diameter?: number;
  21482. tessellation?: number;
  21483. subdivisions?: number;
  21484. arc?: number;
  21485. faceColors?: Color4[];
  21486. faceUV?: Vector4[];
  21487. hasRings?: boolean;
  21488. enclose?: boolean;
  21489. sideOrientation?: number;
  21490. frontUVs?: Vector4;
  21491. backUVs?: Vector4;
  21492. }): VertexData;
  21493. /**
  21494. * Creates the VertexData for a torus
  21495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21496. * * diameter the diameter of the torus, optional default 1
  21497. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21498. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21500. * * 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)
  21501. * * 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)
  21502. * @returns the VertexData of the torus
  21503. */
  21504. static CreateTorus(options: {
  21505. diameter?: number;
  21506. thickness?: number;
  21507. tessellation?: number;
  21508. sideOrientation?: number;
  21509. frontUVs?: Vector4;
  21510. backUVs?: Vector4;
  21511. }): VertexData;
  21512. /**
  21513. * Creates the VertexData of the LineSystem
  21514. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21515. * - lines an array of lines, each line being an array of successive Vector3
  21516. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21517. * @returns the VertexData of the LineSystem
  21518. */
  21519. static CreateLineSystem(options: {
  21520. lines: Vector3[][];
  21521. colors?: Nullable<Color4[][]>;
  21522. }): VertexData;
  21523. /**
  21524. * Create the VertexData for a DashedLines
  21525. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21526. * - points an array successive Vector3
  21527. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21528. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21529. * - dashNb the intended total number of dashes, optional, default 200
  21530. * @returns the VertexData for the DashedLines
  21531. */
  21532. static CreateDashedLines(options: {
  21533. points: Vector3[];
  21534. dashSize?: number;
  21535. gapSize?: number;
  21536. dashNb?: number;
  21537. }): VertexData;
  21538. /**
  21539. * Creates the VertexData for a Ground
  21540. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21541. * - width the width (x direction) of the ground, optional, default 1
  21542. * - height the height (z direction) of the ground, optional, default 1
  21543. * - subdivisions the number of subdivisions per side, optional, default 1
  21544. * @returns the VertexData of the Ground
  21545. */
  21546. static CreateGround(options: {
  21547. width?: number;
  21548. height?: number;
  21549. subdivisions?: number;
  21550. subdivisionsX?: number;
  21551. subdivisionsY?: number;
  21552. }): VertexData;
  21553. /**
  21554. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21555. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21556. * * xmin the ground minimum X coordinate, optional, default -1
  21557. * * zmin the ground minimum Z coordinate, optional, default -1
  21558. * * xmax the ground maximum X coordinate, optional, default 1
  21559. * * zmax the ground maximum Z coordinate, optional, default 1
  21560. * * 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}
  21561. * * 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}
  21562. * @returns the VertexData of the TiledGround
  21563. */
  21564. static CreateTiledGround(options: {
  21565. xmin: number;
  21566. zmin: number;
  21567. xmax: number;
  21568. zmax: number;
  21569. subdivisions?: {
  21570. w: number;
  21571. h: number;
  21572. };
  21573. precision?: {
  21574. w: number;
  21575. h: number;
  21576. };
  21577. }): VertexData;
  21578. /**
  21579. * Creates the VertexData of the Ground designed from a heightmap
  21580. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21581. * * width the width (x direction) of the ground
  21582. * * height the height (z direction) of the ground
  21583. * * subdivisions the number of subdivisions per side
  21584. * * minHeight the minimum altitude on the ground, optional, default 0
  21585. * * maxHeight the maximum altitude on the ground, optional default 1
  21586. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21587. * * buffer the array holding the image color data
  21588. * * bufferWidth the width of image
  21589. * * bufferHeight the height of image
  21590. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21591. * @returns the VertexData of the Ground designed from a heightmap
  21592. */
  21593. static CreateGroundFromHeightMap(options: {
  21594. width: number;
  21595. height: number;
  21596. subdivisions: number;
  21597. minHeight: number;
  21598. maxHeight: number;
  21599. colorFilter: Color3;
  21600. buffer: Uint8Array;
  21601. bufferWidth: number;
  21602. bufferHeight: number;
  21603. alphaFilter: number;
  21604. }): VertexData;
  21605. /**
  21606. * Creates the VertexData for a Plane
  21607. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21608. * * size sets the width and height of the plane to the value of size, optional default 1
  21609. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21610. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21612. * * 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)
  21613. * * 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)
  21614. * @returns the VertexData of the box
  21615. */
  21616. static CreatePlane(options: {
  21617. size?: number;
  21618. width?: number;
  21619. height?: number;
  21620. sideOrientation?: number;
  21621. frontUVs?: Vector4;
  21622. backUVs?: Vector4;
  21623. }): VertexData;
  21624. /**
  21625. * Creates the VertexData of the Disc or regular Polygon
  21626. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21627. * * radius the radius of the disc, optional default 0.5
  21628. * * tessellation the number of polygon sides, optional, default 64
  21629. * * 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
  21630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21631. * * 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)
  21632. * * 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)
  21633. * @returns the VertexData of the box
  21634. */
  21635. static CreateDisc(options: {
  21636. radius?: number;
  21637. tessellation?: number;
  21638. arc?: number;
  21639. sideOrientation?: number;
  21640. frontUVs?: Vector4;
  21641. backUVs?: Vector4;
  21642. }): VertexData;
  21643. /**
  21644. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21645. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21646. * @param polygon a mesh built from polygonTriangulation.build()
  21647. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21648. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21649. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21650. * @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)
  21651. * @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)
  21652. * @returns the VertexData of the Polygon
  21653. */
  21654. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21655. /**
  21656. * Creates the VertexData of the IcoSphere
  21657. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21658. * * radius the radius of the IcoSphere, optional default 1
  21659. * * radiusX allows stretching in the x direction, optional, default radius
  21660. * * radiusY allows stretching in the y direction, optional, default radius
  21661. * * radiusZ allows stretching in the z direction, optional, default radius
  21662. * * flat when true creates a flat shaded mesh, optional, default true
  21663. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21665. * * 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)
  21666. * * 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)
  21667. * @returns the VertexData of the IcoSphere
  21668. */
  21669. static CreateIcoSphere(options: {
  21670. radius?: number;
  21671. radiusX?: number;
  21672. radiusY?: number;
  21673. radiusZ?: number;
  21674. flat?: boolean;
  21675. subdivisions?: number;
  21676. sideOrientation?: number;
  21677. frontUVs?: Vector4;
  21678. backUVs?: Vector4;
  21679. }): VertexData;
  21680. /**
  21681. * Creates the VertexData for a Polyhedron
  21682. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21683. * * type provided types are:
  21684. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21685. * * 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)
  21686. * * size the size of the IcoSphere, optional default 1
  21687. * * sizeX allows stretching in the x direction, optional, default size
  21688. * * sizeY allows stretching in the y direction, optional, default size
  21689. * * sizeZ allows stretching in the z direction, optional, default size
  21690. * * 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
  21691. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21692. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21693. * * flat when true creates a flat shaded mesh, optional, default true
  21694. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21696. * * 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)
  21697. * * 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)
  21698. * @returns the VertexData of the Polyhedron
  21699. */
  21700. static CreatePolyhedron(options: {
  21701. type?: number;
  21702. size?: number;
  21703. sizeX?: number;
  21704. sizeY?: number;
  21705. sizeZ?: number;
  21706. custom?: any;
  21707. faceUV?: Vector4[];
  21708. faceColors?: Color4[];
  21709. flat?: boolean;
  21710. sideOrientation?: number;
  21711. frontUVs?: Vector4;
  21712. backUVs?: Vector4;
  21713. }): VertexData;
  21714. /**
  21715. * Creates the VertexData for a TorusKnot
  21716. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21717. * * radius the radius of the torus knot, optional, default 2
  21718. * * tube the thickness of the tube, optional, default 0.5
  21719. * * radialSegments the number of sides on each tube segments, optional, default 32
  21720. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21721. * * p the number of windings around the z axis, optional, default 2
  21722. * * q the number of windings around the x axis, optional, default 3
  21723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21724. * * 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)
  21725. * * 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)
  21726. * @returns the VertexData of the Torus Knot
  21727. */
  21728. static CreateTorusKnot(options: {
  21729. radius?: number;
  21730. tube?: number;
  21731. radialSegments?: number;
  21732. tubularSegments?: number;
  21733. p?: number;
  21734. q?: number;
  21735. sideOrientation?: number;
  21736. frontUVs?: Vector4;
  21737. backUVs?: Vector4;
  21738. }): VertexData;
  21739. /**
  21740. * Compute normals for given positions and indices
  21741. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21742. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21743. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21744. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21745. * * facetNormals : optional array of facet normals (vector3)
  21746. * * facetPositions : optional array of facet positions (vector3)
  21747. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21748. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21749. * * bInfo : optional bounding info, required for facetPartitioning computation
  21750. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21751. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21752. * * useRightHandedSystem: optional boolean to for right handed system computation
  21753. * * depthSort : optional boolean to enable the facet depth sort computation
  21754. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21755. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21756. */
  21757. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21758. facetNormals?: any;
  21759. facetPositions?: any;
  21760. facetPartitioning?: any;
  21761. ratio?: number;
  21762. bInfo?: any;
  21763. bbSize?: Vector3;
  21764. subDiv?: any;
  21765. useRightHandedSystem?: boolean;
  21766. depthSort?: boolean;
  21767. distanceTo?: Vector3;
  21768. depthSortedFacets?: any;
  21769. }): void;
  21770. /** @hidden */
  21771. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21772. /**
  21773. * Applies VertexData created from the imported parameters to the geometry
  21774. * @param parsedVertexData the parsed data from an imported file
  21775. * @param geometry the geometry to apply the VertexData to
  21776. */
  21777. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21778. }
  21779. }
  21780. declare module BABYLON {
  21781. /**
  21782. * Defines a target to use with MorphTargetManager
  21783. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21784. */
  21785. export class MorphTarget implements IAnimatable {
  21786. /** defines the name of the target */
  21787. name: string;
  21788. /**
  21789. * Gets or sets the list of animations
  21790. */
  21791. animations: Animation[];
  21792. private _scene;
  21793. private _positions;
  21794. private _normals;
  21795. private _tangents;
  21796. private _uvs;
  21797. private _influence;
  21798. /**
  21799. * Observable raised when the influence changes
  21800. */
  21801. onInfluenceChanged: Observable<boolean>;
  21802. /** @hidden */
  21803. _onDataLayoutChanged: Observable<void>;
  21804. /**
  21805. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21806. */
  21807. influence: number;
  21808. /**
  21809. * Gets or sets the id of the morph Target
  21810. */
  21811. id: string;
  21812. private _animationPropertiesOverride;
  21813. /**
  21814. * Gets or sets the animation properties override
  21815. */
  21816. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21817. /**
  21818. * Creates a new MorphTarget
  21819. * @param name defines the name of the target
  21820. * @param influence defines the influence to use
  21821. * @param scene defines the scene the morphtarget belongs to
  21822. */
  21823. constructor(
  21824. /** defines the name of the target */
  21825. name: string, influence?: number, scene?: Nullable<Scene>);
  21826. /**
  21827. * Gets a boolean defining if the target contains position data
  21828. */
  21829. readonly hasPositions: boolean;
  21830. /**
  21831. * Gets a boolean defining if the target contains normal data
  21832. */
  21833. readonly hasNormals: boolean;
  21834. /**
  21835. * Gets a boolean defining if the target contains tangent data
  21836. */
  21837. readonly hasTangents: boolean;
  21838. /**
  21839. * Gets a boolean defining if the target contains texture coordinates data
  21840. */
  21841. readonly hasUVs: boolean;
  21842. /**
  21843. * Affects position data to this target
  21844. * @param data defines the position data to use
  21845. */
  21846. setPositions(data: Nullable<FloatArray>): void;
  21847. /**
  21848. * Gets the position data stored in this target
  21849. * @returns a FloatArray containing the position data (or null if not present)
  21850. */
  21851. getPositions(): Nullable<FloatArray>;
  21852. /**
  21853. * Affects normal data to this target
  21854. * @param data defines the normal data to use
  21855. */
  21856. setNormals(data: Nullable<FloatArray>): void;
  21857. /**
  21858. * Gets the normal data stored in this target
  21859. * @returns a FloatArray containing the normal data (or null if not present)
  21860. */
  21861. getNormals(): Nullable<FloatArray>;
  21862. /**
  21863. * Affects tangent data to this target
  21864. * @param data defines the tangent data to use
  21865. */
  21866. setTangents(data: Nullable<FloatArray>): void;
  21867. /**
  21868. * Gets the tangent data stored in this target
  21869. * @returns a FloatArray containing the tangent data (or null if not present)
  21870. */
  21871. getTangents(): Nullable<FloatArray>;
  21872. /**
  21873. * Affects texture coordinates data to this target
  21874. * @param data defines the texture coordinates data to use
  21875. */
  21876. setUVs(data: Nullable<FloatArray>): void;
  21877. /**
  21878. * Gets the texture coordinates data stored in this target
  21879. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21880. */
  21881. getUVs(): Nullable<FloatArray>;
  21882. /**
  21883. * Serializes the current target into a Serialization object
  21884. * @returns the serialized object
  21885. */
  21886. serialize(): any;
  21887. /**
  21888. * Returns the string "MorphTarget"
  21889. * @returns "MorphTarget"
  21890. */
  21891. getClassName(): string;
  21892. /**
  21893. * Creates a new target from serialized data
  21894. * @param serializationObject defines the serialized data to use
  21895. * @returns a new MorphTarget
  21896. */
  21897. static Parse(serializationObject: any): MorphTarget;
  21898. /**
  21899. * Creates a MorphTarget from mesh data
  21900. * @param mesh defines the source mesh
  21901. * @param name defines the name to use for the new target
  21902. * @param influence defines the influence to attach to the target
  21903. * @returns a new MorphTarget
  21904. */
  21905. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21906. }
  21907. }
  21908. declare module BABYLON {
  21909. /**
  21910. * This class is used to deform meshes using morphing between different targets
  21911. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21912. */
  21913. export class MorphTargetManager {
  21914. private _targets;
  21915. private _targetInfluenceChangedObservers;
  21916. private _targetDataLayoutChangedObservers;
  21917. private _activeTargets;
  21918. private _scene;
  21919. private _influences;
  21920. private _supportsNormals;
  21921. private _supportsTangents;
  21922. private _supportsUVs;
  21923. private _vertexCount;
  21924. private _uniqueId;
  21925. private _tempInfluences;
  21926. /**
  21927. * Gets or sets a boolean indicating if normals must be morphed
  21928. */
  21929. enableNormalMorphing: boolean;
  21930. /**
  21931. * Gets or sets a boolean indicating if tangents must be morphed
  21932. */
  21933. enableTangentMorphing: boolean;
  21934. /**
  21935. * Gets or sets a boolean indicating if UV must be morphed
  21936. */
  21937. enableUVMorphing: boolean;
  21938. /**
  21939. * Creates a new MorphTargetManager
  21940. * @param scene defines the current scene
  21941. */
  21942. constructor(scene?: Nullable<Scene>);
  21943. /**
  21944. * Gets the unique ID of this manager
  21945. */
  21946. readonly uniqueId: number;
  21947. /**
  21948. * Gets the number of vertices handled by this manager
  21949. */
  21950. readonly vertexCount: number;
  21951. /**
  21952. * Gets a boolean indicating if this manager supports morphing of normals
  21953. */
  21954. readonly supportsNormals: boolean;
  21955. /**
  21956. * Gets a boolean indicating if this manager supports morphing of tangents
  21957. */
  21958. readonly supportsTangents: boolean;
  21959. /**
  21960. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21961. */
  21962. readonly supportsUVs: boolean;
  21963. /**
  21964. * Gets the number of targets stored in this manager
  21965. */
  21966. readonly numTargets: number;
  21967. /**
  21968. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21969. */
  21970. readonly numInfluencers: number;
  21971. /**
  21972. * Gets the list of influences (one per target)
  21973. */
  21974. readonly influences: Float32Array;
  21975. /**
  21976. * Gets the active target at specified index. An active target is a target with an influence > 0
  21977. * @param index defines the index to check
  21978. * @returns the requested target
  21979. */
  21980. getActiveTarget(index: number): MorphTarget;
  21981. /**
  21982. * Gets the target at specified index
  21983. * @param index defines the index to check
  21984. * @returns the requested target
  21985. */
  21986. getTarget(index: number): MorphTarget;
  21987. /**
  21988. * Add a new target to this manager
  21989. * @param target defines the target to add
  21990. */
  21991. addTarget(target: MorphTarget): void;
  21992. /**
  21993. * Removes a target from the manager
  21994. * @param target defines the target to remove
  21995. */
  21996. removeTarget(target: MorphTarget): void;
  21997. /**
  21998. * Serializes the current manager into a Serialization object
  21999. * @returns the serialized object
  22000. */
  22001. serialize(): any;
  22002. private _syncActiveTargets;
  22003. /**
  22004. * Syncrhonize the targets with all the meshes using this morph target manager
  22005. */
  22006. synchronize(): void;
  22007. /**
  22008. * Creates a new MorphTargetManager from serialized data
  22009. * @param serializationObject defines the serialized data
  22010. * @param scene defines the hosting scene
  22011. * @returns the new MorphTargetManager
  22012. */
  22013. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22014. }
  22015. }
  22016. declare module BABYLON {
  22017. /**
  22018. * Class used to represent a specific level of detail of a mesh
  22019. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22020. */
  22021. export class MeshLODLevel {
  22022. /** Defines the distance where this level should star being displayed */
  22023. distance: number;
  22024. /** Defines the mesh to use to render this level */
  22025. mesh: Nullable<Mesh>;
  22026. /**
  22027. * Creates a new LOD level
  22028. * @param distance defines the distance where this level should star being displayed
  22029. * @param mesh defines the mesh to use to render this level
  22030. */
  22031. constructor(
  22032. /** Defines the distance where this level should star being displayed */
  22033. distance: number,
  22034. /** Defines the mesh to use to render this level */
  22035. mesh: Nullable<Mesh>);
  22036. }
  22037. }
  22038. declare module BABYLON {
  22039. /**
  22040. * Mesh representing the gorund
  22041. */
  22042. export class GroundMesh extends Mesh {
  22043. /** If octree should be generated */
  22044. generateOctree: boolean;
  22045. private _heightQuads;
  22046. /** @hidden */
  22047. _subdivisionsX: number;
  22048. /** @hidden */
  22049. _subdivisionsY: number;
  22050. /** @hidden */
  22051. _width: number;
  22052. /** @hidden */
  22053. _height: number;
  22054. /** @hidden */
  22055. _minX: number;
  22056. /** @hidden */
  22057. _maxX: number;
  22058. /** @hidden */
  22059. _minZ: number;
  22060. /** @hidden */
  22061. _maxZ: number;
  22062. constructor(name: string, scene: Scene);
  22063. /**
  22064. * "GroundMesh"
  22065. * @returns "GroundMesh"
  22066. */
  22067. getClassName(): string;
  22068. /**
  22069. * The minimum of x and y subdivisions
  22070. */
  22071. readonly subdivisions: number;
  22072. /**
  22073. * X subdivisions
  22074. */
  22075. readonly subdivisionsX: number;
  22076. /**
  22077. * Y subdivisions
  22078. */
  22079. readonly subdivisionsY: number;
  22080. /**
  22081. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22082. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22083. * @param chunksCount the number of subdivisions for x and y
  22084. * @param octreeBlocksSize (Default: 32)
  22085. */
  22086. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22087. /**
  22088. * Returns a height (y) value in the Worl system :
  22089. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22090. * @param x x coordinate
  22091. * @param z z coordinate
  22092. * @returns the ground y position if (x, z) are outside the ground surface.
  22093. */
  22094. getHeightAtCoordinates(x: number, z: number): number;
  22095. /**
  22096. * Returns a normalized vector (Vector3) orthogonal to the ground
  22097. * at the ground coordinates (x, z) expressed in the World system.
  22098. * @param x x coordinate
  22099. * @param z z coordinate
  22100. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22101. */
  22102. getNormalAtCoordinates(x: number, z: number): Vector3;
  22103. /**
  22104. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22105. * at the ground coordinates (x, z) expressed in the World system.
  22106. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22107. * @param x x coordinate
  22108. * @param z z coordinate
  22109. * @param ref vector to store the result
  22110. * @returns the GroundMesh.
  22111. */
  22112. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22113. /**
  22114. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22115. * if the ground has been updated.
  22116. * This can be used in the render loop.
  22117. * @returns the GroundMesh.
  22118. */
  22119. updateCoordinateHeights(): GroundMesh;
  22120. private _getFacetAt;
  22121. private _initHeightQuads;
  22122. private _computeHeightQuads;
  22123. /**
  22124. * Serializes this ground mesh
  22125. * @param serializationObject object to write serialization to
  22126. */
  22127. serialize(serializationObject: any): void;
  22128. /**
  22129. * Parses a serialized ground mesh
  22130. * @param parsedMesh the serialized mesh
  22131. * @param scene the scene to create the ground mesh in
  22132. * @returns the created ground mesh
  22133. */
  22134. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22135. }
  22136. }
  22137. declare module BABYLON {
  22138. /**
  22139. * Interface for Physics-Joint data
  22140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22141. */
  22142. export interface PhysicsJointData {
  22143. /**
  22144. * The main pivot of the joint
  22145. */
  22146. mainPivot?: Vector3;
  22147. /**
  22148. * The connected pivot of the joint
  22149. */
  22150. connectedPivot?: Vector3;
  22151. /**
  22152. * The main axis of the joint
  22153. */
  22154. mainAxis?: Vector3;
  22155. /**
  22156. * The connected axis of the joint
  22157. */
  22158. connectedAxis?: Vector3;
  22159. /**
  22160. * The collision of the joint
  22161. */
  22162. collision?: boolean;
  22163. /**
  22164. * Native Oimo/Cannon/Energy data
  22165. */
  22166. nativeParams?: any;
  22167. }
  22168. /**
  22169. * This is a holder class for the physics joint created by the physics plugin
  22170. * It holds a set of functions to control the underlying joint
  22171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22172. */
  22173. export class PhysicsJoint {
  22174. /**
  22175. * The type of the physics joint
  22176. */
  22177. type: number;
  22178. /**
  22179. * The data for the physics joint
  22180. */
  22181. jointData: PhysicsJointData;
  22182. private _physicsJoint;
  22183. protected _physicsPlugin: IPhysicsEnginePlugin;
  22184. /**
  22185. * Initializes the physics joint
  22186. * @param type The type of the physics joint
  22187. * @param jointData The data for the physics joint
  22188. */
  22189. constructor(
  22190. /**
  22191. * The type of the physics joint
  22192. */
  22193. type: number,
  22194. /**
  22195. * The data for the physics joint
  22196. */
  22197. jointData: PhysicsJointData);
  22198. /**
  22199. * Gets the physics joint
  22200. */
  22201. /**
  22202. * Sets the physics joint
  22203. */
  22204. physicsJoint: any;
  22205. /**
  22206. * Sets the physics plugin
  22207. */
  22208. physicsPlugin: IPhysicsEnginePlugin;
  22209. /**
  22210. * Execute a function that is physics-plugin specific.
  22211. * @param {Function} func the function that will be executed.
  22212. * It accepts two parameters: the physics world and the physics joint
  22213. */
  22214. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22215. /**
  22216. * Distance-Joint type
  22217. */
  22218. static DistanceJoint: number;
  22219. /**
  22220. * Hinge-Joint type
  22221. */
  22222. static HingeJoint: number;
  22223. /**
  22224. * Ball-and-Socket joint type
  22225. */
  22226. static BallAndSocketJoint: number;
  22227. /**
  22228. * Wheel-Joint type
  22229. */
  22230. static WheelJoint: number;
  22231. /**
  22232. * Slider-Joint type
  22233. */
  22234. static SliderJoint: number;
  22235. /**
  22236. * Prismatic-Joint type
  22237. */
  22238. static PrismaticJoint: number;
  22239. /**
  22240. * Universal-Joint type
  22241. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22242. */
  22243. static UniversalJoint: number;
  22244. /**
  22245. * Hinge-Joint 2 type
  22246. */
  22247. static Hinge2Joint: number;
  22248. /**
  22249. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22250. */
  22251. static PointToPointJoint: number;
  22252. /**
  22253. * Spring-Joint type
  22254. */
  22255. static SpringJoint: number;
  22256. /**
  22257. * Lock-Joint type
  22258. */
  22259. static LockJoint: number;
  22260. }
  22261. /**
  22262. * A class representing a physics distance joint
  22263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22264. */
  22265. export class DistanceJoint extends PhysicsJoint {
  22266. /**
  22267. *
  22268. * @param jointData The data for the Distance-Joint
  22269. */
  22270. constructor(jointData: DistanceJointData);
  22271. /**
  22272. * Update the predefined distance.
  22273. * @param maxDistance The maximum preferred distance
  22274. * @param minDistance The minimum preferred distance
  22275. */
  22276. updateDistance(maxDistance: number, minDistance?: number): void;
  22277. }
  22278. /**
  22279. * Represents a Motor-Enabled Joint
  22280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22281. */
  22282. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22283. /**
  22284. * Initializes the Motor-Enabled Joint
  22285. * @param type The type of the joint
  22286. * @param jointData The physica joint data for the joint
  22287. */
  22288. constructor(type: number, jointData: PhysicsJointData);
  22289. /**
  22290. * Set the motor values.
  22291. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22292. * @param force the force to apply
  22293. * @param maxForce max force for this motor.
  22294. */
  22295. setMotor(force?: number, maxForce?: number): void;
  22296. /**
  22297. * Set the motor's limits.
  22298. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22299. * @param upperLimit The upper limit of the motor
  22300. * @param lowerLimit The lower limit of the motor
  22301. */
  22302. setLimit(upperLimit: number, lowerLimit?: number): void;
  22303. }
  22304. /**
  22305. * This class represents a single physics Hinge-Joint
  22306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22307. */
  22308. export class HingeJoint extends MotorEnabledJoint {
  22309. /**
  22310. * Initializes the Hinge-Joint
  22311. * @param jointData The joint data for the Hinge-Joint
  22312. */
  22313. constructor(jointData: PhysicsJointData);
  22314. /**
  22315. * Set the motor values.
  22316. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22317. * @param {number} force the force to apply
  22318. * @param {number} maxForce max force for this motor.
  22319. */
  22320. setMotor(force?: number, maxForce?: number): void;
  22321. /**
  22322. * Set the motor's limits.
  22323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22324. * @param upperLimit The upper limit of the motor
  22325. * @param lowerLimit The lower limit of the motor
  22326. */
  22327. setLimit(upperLimit: number, lowerLimit?: number): void;
  22328. }
  22329. /**
  22330. * This class represents a dual hinge physics joint (same as wheel joint)
  22331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22332. */
  22333. export class Hinge2Joint extends MotorEnabledJoint {
  22334. /**
  22335. * Initializes the Hinge2-Joint
  22336. * @param jointData The joint data for the Hinge2-Joint
  22337. */
  22338. constructor(jointData: PhysicsJointData);
  22339. /**
  22340. * Set the motor values.
  22341. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22342. * @param {number} targetSpeed the speed the motor is to reach
  22343. * @param {number} maxForce max force for this motor.
  22344. * @param {motorIndex} the motor's index, 0 or 1.
  22345. */
  22346. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22347. /**
  22348. * Set the motor limits.
  22349. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22350. * @param {number} upperLimit the upper limit
  22351. * @param {number} lowerLimit lower limit
  22352. * @param {motorIndex} the motor's index, 0 or 1.
  22353. */
  22354. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22355. }
  22356. /**
  22357. * Interface for a motor enabled joint
  22358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22359. */
  22360. export interface IMotorEnabledJoint {
  22361. /**
  22362. * Physics joint
  22363. */
  22364. physicsJoint: any;
  22365. /**
  22366. * Sets the motor of the motor-enabled joint
  22367. * @param force The force of the motor
  22368. * @param maxForce The maximum force of the motor
  22369. * @param motorIndex The index of the motor
  22370. */
  22371. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22372. /**
  22373. * Sets the limit of the motor
  22374. * @param upperLimit The upper limit of the motor
  22375. * @param lowerLimit The lower limit of the motor
  22376. * @param motorIndex The index of the motor
  22377. */
  22378. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22379. }
  22380. /**
  22381. * Joint data for a Distance-Joint
  22382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22383. */
  22384. export interface DistanceJointData extends PhysicsJointData {
  22385. /**
  22386. * Max distance the 2 joint objects can be apart
  22387. */
  22388. maxDistance: number;
  22389. }
  22390. /**
  22391. * Joint data from a spring joint
  22392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22393. */
  22394. export interface SpringJointData extends PhysicsJointData {
  22395. /**
  22396. * Length of the spring
  22397. */
  22398. length: number;
  22399. /**
  22400. * Stiffness of the spring
  22401. */
  22402. stiffness: number;
  22403. /**
  22404. * Damping of the spring
  22405. */
  22406. damping: number;
  22407. /** this callback will be called when applying the force to the impostors. */
  22408. forceApplicationCallback: () => void;
  22409. }
  22410. }
  22411. declare module BABYLON {
  22412. /**
  22413. * Holds the data for the raycast result
  22414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22415. */
  22416. export class PhysicsRaycastResult {
  22417. private _hasHit;
  22418. private _hitDistance;
  22419. private _hitNormalWorld;
  22420. private _hitPointWorld;
  22421. private _rayFromWorld;
  22422. private _rayToWorld;
  22423. /**
  22424. * Gets if there was a hit
  22425. */
  22426. readonly hasHit: boolean;
  22427. /**
  22428. * Gets the distance from the hit
  22429. */
  22430. readonly hitDistance: number;
  22431. /**
  22432. * Gets the hit normal/direction in the world
  22433. */
  22434. readonly hitNormalWorld: Vector3;
  22435. /**
  22436. * Gets the hit point in the world
  22437. */
  22438. readonly hitPointWorld: Vector3;
  22439. /**
  22440. * Gets the ray "start point" of the ray in the world
  22441. */
  22442. readonly rayFromWorld: Vector3;
  22443. /**
  22444. * Gets the ray "end point" of the ray in the world
  22445. */
  22446. readonly rayToWorld: Vector3;
  22447. /**
  22448. * Sets the hit data (normal & point in world space)
  22449. * @param hitNormalWorld defines the normal in world space
  22450. * @param hitPointWorld defines the point in world space
  22451. */
  22452. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22453. /**
  22454. * Sets the distance from the start point to the hit point
  22455. * @param distance
  22456. */
  22457. setHitDistance(distance: number): void;
  22458. /**
  22459. * Calculates the distance manually
  22460. */
  22461. calculateHitDistance(): void;
  22462. /**
  22463. * Resets all the values to default
  22464. * @param from The from point on world space
  22465. * @param to The to point on world space
  22466. */
  22467. reset(from?: Vector3, to?: Vector3): void;
  22468. }
  22469. /**
  22470. * Interface for the size containing width and height
  22471. */
  22472. interface IXYZ {
  22473. /**
  22474. * X
  22475. */
  22476. x: number;
  22477. /**
  22478. * Y
  22479. */
  22480. y: number;
  22481. /**
  22482. * Z
  22483. */
  22484. z: number;
  22485. }
  22486. }
  22487. declare module BABYLON {
  22488. /**
  22489. * Interface used to describe a physics joint
  22490. */
  22491. export interface PhysicsImpostorJoint {
  22492. /** Defines the main impostor to which the joint is linked */
  22493. mainImpostor: PhysicsImpostor;
  22494. /** Defines the impostor that is connected to the main impostor using this joint */
  22495. connectedImpostor: PhysicsImpostor;
  22496. /** Defines the joint itself */
  22497. joint: PhysicsJoint;
  22498. }
  22499. /** @hidden */
  22500. export interface IPhysicsEnginePlugin {
  22501. world: any;
  22502. name: string;
  22503. setGravity(gravity: Vector3): void;
  22504. setTimeStep(timeStep: number): void;
  22505. getTimeStep(): number;
  22506. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22507. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22508. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22509. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22510. removePhysicsBody(impostor: PhysicsImpostor): void;
  22511. generateJoint(joint: PhysicsImpostorJoint): void;
  22512. removeJoint(joint: PhysicsImpostorJoint): void;
  22513. isSupported(): boolean;
  22514. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22515. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22516. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22517. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22518. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22519. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22520. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22521. getBodyMass(impostor: PhysicsImpostor): number;
  22522. getBodyFriction(impostor: PhysicsImpostor): number;
  22523. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22524. getBodyRestitution(impostor: PhysicsImpostor): number;
  22525. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22526. getBodyPressure?(impostor: PhysicsImpostor): number;
  22527. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22528. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22529. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22530. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22531. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22532. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22533. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22534. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22535. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22536. sleepBody(impostor: PhysicsImpostor): void;
  22537. wakeUpBody(impostor: PhysicsImpostor): void;
  22538. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22539. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22540. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22541. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22542. getRadius(impostor: PhysicsImpostor): number;
  22543. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22544. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22545. dispose(): void;
  22546. }
  22547. /**
  22548. * Interface used to define a physics engine
  22549. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22550. */
  22551. export interface IPhysicsEngine {
  22552. /**
  22553. * Gets the gravity vector used by the simulation
  22554. */
  22555. gravity: Vector3;
  22556. /**
  22557. * Sets the gravity vector used by the simulation
  22558. * @param gravity defines the gravity vector to use
  22559. */
  22560. setGravity(gravity: Vector3): void;
  22561. /**
  22562. * Set the time step of the physics engine.
  22563. * Default is 1/60.
  22564. * To slow it down, enter 1/600 for example.
  22565. * To speed it up, 1/30
  22566. * @param newTimeStep the new timestep to apply to this world.
  22567. */
  22568. setTimeStep(newTimeStep: number): void;
  22569. /**
  22570. * Get the time step of the physics engine.
  22571. * @returns the current time step
  22572. */
  22573. getTimeStep(): number;
  22574. /**
  22575. * Release all resources
  22576. */
  22577. dispose(): void;
  22578. /**
  22579. * Gets the name of the current physics plugin
  22580. * @returns the name of the plugin
  22581. */
  22582. getPhysicsPluginName(): string;
  22583. /**
  22584. * Adding a new impostor for the impostor tracking.
  22585. * This will be done by the impostor itself.
  22586. * @param impostor the impostor to add
  22587. */
  22588. addImpostor(impostor: PhysicsImpostor): void;
  22589. /**
  22590. * Remove an impostor from the engine.
  22591. * This impostor and its mesh will not longer be updated by the physics engine.
  22592. * @param impostor the impostor to remove
  22593. */
  22594. removeImpostor(impostor: PhysicsImpostor): void;
  22595. /**
  22596. * Add a joint to the physics engine
  22597. * @param mainImpostor defines the main impostor to which the joint is added.
  22598. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22599. * @param joint defines the joint that will connect both impostors.
  22600. */
  22601. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22602. /**
  22603. * Removes a joint from the simulation
  22604. * @param mainImpostor defines the impostor used with the joint
  22605. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22606. * @param joint defines the joint to remove
  22607. */
  22608. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22609. /**
  22610. * Gets the current plugin used to run the simulation
  22611. * @returns current plugin
  22612. */
  22613. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22614. /**
  22615. * Gets the list of physic impostors
  22616. * @returns an array of PhysicsImpostor
  22617. */
  22618. getImpostors(): Array<PhysicsImpostor>;
  22619. /**
  22620. * Gets the impostor for a physics enabled object
  22621. * @param object defines the object impersonated by the impostor
  22622. * @returns the PhysicsImpostor or null if not found
  22623. */
  22624. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22625. /**
  22626. * Gets the impostor for a physics body object
  22627. * @param body defines physics body used by the impostor
  22628. * @returns the PhysicsImpostor or null if not found
  22629. */
  22630. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22631. /**
  22632. * Does a raycast in the physics world
  22633. * @param from when should the ray start?
  22634. * @param to when should the ray end?
  22635. * @returns PhysicsRaycastResult
  22636. */
  22637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22638. /**
  22639. * Called by the scene. No need to call it.
  22640. * @param delta defines the timespam between frames
  22641. */
  22642. _step(delta: number): void;
  22643. }
  22644. }
  22645. declare module BABYLON {
  22646. /**
  22647. * The interface for the physics imposter parameters
  22648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22649. */
  22650. export interface PhysicsImpostorParameters {
  22651. /**
  22652. * The mass of the physics imposter
  22653. */
  22654. mass: number;
  22655. /**
  22656. * The friction of the physics imposter
  22657. */
  22658. friction?: number;
  22659. /**
  22660. * The coefficient of restitution of the physics imposter
  22661. */
  22662. restitution?: number;
  22663. /**
  22664. * The native options of the physics imposter
  22665. */
  22666. nativeOptions?: any;
  22667. /**
  22668. * Specifies if the parent should be ignored
  22669. */
  22670. ignoreParent?: boolean;
  22671. /**
  22672. * Specifies if bi-directional transformations should be disabled
  22673. */
  22674. disableBidirectionalTransformation?: boolean;
  22675. /**
  22676. * The pressure inside the physics imposter, soft object only
  22677. */
  22678. pressure?: number;
  22679. /**
  22680. * The stiffness the physics imposter, soft object only
  22681. */
  22682. stiffness?: number;
  22683. /**
  22684. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22685. */
  22686. velocityIterations?: number;
  22687. /**
  22688. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22689. */
  22690. positionIterations?: number;
  22691. /**
  22692. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22693. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22694. * Add to fix multiple points
  22695. */
  22696. fixedPoints?: number;
  22697. /**
  22698. * The collision margin around a soft object
  22699. */
  22700. margin?: number;
  22701. /**
  22702. * The collision margin around a soft object
  22703. */
  22704. damping?: number;
  22705. /**
  22706. * The path for a rope based on an extrusion
  22707. */
  22708. path?: any;
  22709. /**
  22710. * The shape of an extrusion used for a rope based on an extrusion
  22711. */
  22712. shape?: any;
  22713. }
  22714. /**
  22715. * Interface for a physics-enabled object
  22716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22717. */
  22718. export interface IPhysicsEnabledObject {
  22719. /**
  22720. * The position of the physics-enabled object
  22721. */
  22722. position: Vector3;
  22723. /**
  22724. * The rotation of the physics-enabled object
  22725. */
  22726. rotationQuaternion: Nullable<Quaternion>;
  22727. /**
  22728. * The scale of the physics-enabled object
  22729. */
  22730. scaling: Vector3;
  22731. /**
  22732. * The rotation of the physics-enabled object
  22733. */
  22734. rotation?: Vector3;
  22735. /**
  22736. * The parent of the physics-enabled object
  22737. */
  22738. parent?: any;
  22739. /**
  22740. * The bounding info of the physics-enabled object
  22741. * @returns The bounding info of the physics-enabled object
  22742. */
  22743. getBoundingInfo(): BoundingInfo;
  22744. /**
  22745. * Computes the world matrix
  22746. * @param force Specifies if the world matrix should be computed by force
  22747. * @returns A world matrix
  22748. */
  22749. computeWorldMatrix(force: boolean): Matrix;
  22750. /**
  22751. * Gets the world matrix
  22752. * @returns A world matrix
  22753. */
  22754. getWorldMatrix?(): Matrix;
  22755. /**
  22756. * Gets the child meshes
  22757. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22758. * @returns An array of abstract meshes
  22759. */
  22760. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22761. /**
  22762. * Gets the vertex data
  22763. * @param kind The type of vertex data
  22764. * @returns A nullable array of numbers, or a float32 array
  22765. */
  22766. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22767. /**
  22768. * Gets the indices from the mesh
  22769. * @returns A nullable array of index arrays
  22770. */
  22771. getIndices?(): Nullable<IndicesArray>;
  22772. /**
  22773. * Gets the scene from the mesh
  22774. * @returns the indices array or null
  22775. */
  22776. getScene?(): Scene;
  22777. /**
  22778. * Gets the absolute position from the mesh
  22779. * @returns the absolute position
  22780. */
  22781. getAbsolutePosition(): Vector3;
  22782. /**
  22783. * Gets the absolute pivot point from the mesh
  22784. * @returns the absolute pivot point
  22785. */
  22786. getAbsolutePivotPoint(): Vector3;
  22787. /**
  22788. * Rotates the mesh
  22789. * @param axis The axis of rotation
  22790. * @param amount The amount of rotation
  22791. * @param space The space of the rotation
  22792. * @returns The rotation transform node
  22793. */
  22794. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22795. /**
  22796. * Translates the mesh
  22797. * @param axis The axis of translation
  22798. * @param distance The distance of translation
  22799. * @param space The space of the translation
  22800. * @returns The transform node
  22801. */
  22802. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22803. /**
  22804. * Sets the absolute position of the mesh
  22805. * @param absolutePosition The absolute position of the mesh
  22806. * @returns The transform node
  22807. */
  22808. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22809. /**
  22810. * Gets the class name of the mesh
  22811. * @returns The class name
  22812. */
  22813. getClassName(): string;
  22814. }
  22815. /**
  22816. * Represents a physics imposter
  22817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22818. */
  22819. export class PhysicsImpostor {
  22820. /**
  22821. * The physics-enabled object used as the physics imposter
  22822. */
  22823. object: IPhysicsEnabledObject;
  22824. /**
  22825. * The type of the physics imposter
  22826. */
  22827. type: number;
  22828. private _options;
  22829. private _scene?;
  22830. /**
  22831. * The default object size of the imposter
  22832. */
  22833. static DEFAULT_OBJECT_SIZE: Vector3;
  22834. /**
  22835. * The identity quaternion of the imposter
  22836. */
  22837. static IDENTITY_QUATERNION: Quaternion;
  22838. /** @hidden */
  22839. _pluginData: any;
  22840. private _physicsEngine;
  22841. private _physicsBody;
  22842. private _bodyUpdateRequired;
  22843. private _onBeforePhysicsStepCallbacks;
  22844. private _onAfterPhysicsStepCallbacks;
  22845. /** @hidden */
  22846. _onPhysicsCollideCallbacks: Array<{
  22847. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22848. otherImpostors: Array<PhysicsImpostor>;
  22849. }>;
  22850. private _deltaPosition;
  22851. private _deltaRotation;
  22852. private _deltaRotationConjugated;
  22853. /** @hidden */
  22854. _isFromLine: boolean;
  22855. private _parent;
  22856. private _isDisposed;
  22857. private static _tmpVecs;
  22858. private static _tmpQuat;
  22859. /**
  22860. * Specifies if the physics imposter is disposed
  22861. */
  22862. readonly isDisposed: boolean;
  22863. /**
  22864. * Gets the mass of the physics imposter
  22865. */
  22866. mass: number;
  22867. /**
  22868. * Gets the coefficient of friction
  22869. */
  22870. /**
  22871. * Sets the coefficient of friction
  22872. */
  22873. friction: number;
  22874. /**
  22875. * Gets the coefficient of restitution
  22876. */
  22877. /**
  22878. * Sets the coefficient of restitution
  22879. */
  22880. restitution: number;
  22881. /**
  22882. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22883. */
  22884. /**
  22885. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22886. */
  22887. pressure: number;
  22888. /**
  22889. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22890. */
  22891. /**
  22892. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22893. */
  22894. stiffness: number;
  22895. /**
  22896. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22897. */
  22898. /**
  22899. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22900. */
  22901. velocityIterations: number;
  22902. /**
  22903. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22904. */
  22905. /**
  22906. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22907. */
  22908. positionIterations: number;
  22909. /**
  22910. * The unique id of the physics imposter
  22911. * set by the physics engine when adding this impostor to the array
  22912. */
  22913. uniqueId: number;
  22914. /**
  22915. * @hidden
  22916. */
  22917. soft: boolean;
  22918. /**
  22919. * @hidden
  22920. */
  22921. segments: number;
  22922. private _joints;
  22923. /**
  22924. * Initializes the physics imposter
  22925. * @param object The physics-enabled object used as the physics imposter
  22926. * @param type The type of the physics imposter
  22927. * @param _options The options for the physics imposter
  22928. * @param _scene The Babylon scene
  22929. */
  22930. constructor(
  22931. /**
  22932. * The physics-enabled object used as the physics imposter
  22933. */
  22934. object: IPhysicsEnabledObject,
  22935. /**
  22936. * The type of the physics imposter
  22937. */
  22938. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22939. /**
  22940. * This function will completly initialize this impostor.
  22941. * It will create a new body - but only if this mesh has no parent.
  22942. * If it has, this impostor will not be used other than to define the impostor
  22943. * of the child mesh.
  22944. * @hidden
  22945. */
  22946. _init(): void;
  22947. private _getPhysicsParent;
  22948. /**
  22949. * Should a new body be generated.
  22950. * @returns boolean specifying if body initialization is required
  22951. */
  22952. isBodyInitRequired(): boolean;
  22953. /**
  22954. * Sets the updated scaling
  22955. * @param updated Specifies if the scaling is updated
  22956. */
  22957. setScalingUpdated(): void;
  22958. /**
  22959. * Force a regeneration of this or the parent's impostor's body.
  22960. * Use under cautious - This will remove all joints already implemented.
  22961. */
  22962. forceUpdate(): void;
  22963. /**
  22964. * Gets the body that holds this impostor. Either its own, or its parent.
  22965. */
  22966. /**
  22967. * Set the physics body. Used mainly by the physics engine/plugin
  22968. */
  22969. physicsBody: any;
  22970. /**
  22971. * Get the parent of the physics imposter
  22972. * @returns Physics imposter or null
  22973. */
  22974. /**
  22975. * Sets the parent of the physics imposter
  22976. */
  22977. parent: Nullable<PhysicsImpostor>;
  22978. /**
  22979. * Resets the update flags
  22980. */
  22981. resetUpdateFlags(): void;
  22982. /**
  22983. * Gets the object extend size
  22984. * @returns the object extend size
  22985. */
  22986. getObjectExtendSize(): Vector3;
  22987. /**
  22988. * Gets the object center
  22989. * @returns The object center
  22990. */
  22991. getObjectCenter(): Vector3;
  22992. /**
  22993. * Get a specific parametes from the options parameter
  22994. * @param paramName The object parameter name
  22995. * @returns The object parameter
  22996. */
  22997. getParam(paramName: string): any;
  22998. /**
  22999. * Sets a specific parameter in the options given to the physics plugin
  23000. * @param paramName The parameter name
  23001. * @param value The value of the parameter
  23002. */
  23003. setParam(paramName: string, value: number): void;
  23004. /**
  23005. * Specifically change the body's mass option. Won't recreate the physics body object
  23006. * @param mass The mass of the physics imposter
  23007. */
  23008. setMass(mass: number): void;
  23009. /**
  23010. * Gets the linear velocity
  23011. * @returns linear velocity or null
  23012. */
  23013. getLinearVelocity(): Nullable<Vector3>;
  23014. /**
  23015. * Sets the linear velocity
  23016. * @param velocity linear velocity or null
  23017. */
  23018. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23019. /**
  23020. * Gets the angular velocity
  23021. * @returns angular velocity or null
  23022. */
  23023. getAngularVelocity(): Nullable<Vector3>;
  23024. /**
  23025. * Sets the angular velocity
  23026. * @param velocity The velocity or null
  23027. */
  23028. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23029. /**
  23030. * Execute a function with the physics plugin native code
  23031. * Provide a function the will have two variables - the world object and the physics body object
  23032. * @param func The function to execute with the physics plugin native code
  23033. */
  23034. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23035. /**
  23036. * Register a function that will be executed before the physics world is stepping forward
  23037. * @param func The function to execute before the physics world is stepped forward
  23038. */
  23039. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23040. /**
  23041. * Unregister a function that will be executed before the physics world is stepping forward
  23042. * @param func The function to execute before the physics world is stepped forward
  23043. */
  23044. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23045. /**
  23046. * Register a function that will be executed after the physics step
  23047. * @param func The function to execute after physics step
  23048. */
  23049. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23050. /**
  23051. * Unregisters a function that will be executed after the physics step
  23052. * @param func The function to execute after physics step
  23053. */
  23054. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23055. /**
  23056. * register a function that will be executed when this impostor collides against a different body
  23057. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23058. * @param func Callback that is executed on collision
  23059. */
  23060. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23061. /**
  23062. * Unregisters the physics imposter on contact
  23063. * @param collideAgainst The physics object to collide against
  23064. * @param func Callback to execute on collision
  23065. */
  23066. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23067. private _tmpQuat;
  23068. private _tmpQuat2;
  23069. /**
  23070. * Get the parent rotation
  23071. * @returns The parent rotation
  23072. */
  23073. getParentsRotation(): Quaternion;
  23074. /**
  23075. * this function is executed by the physics engine.
  23076. */
  23077. beforeStep: () => void;
  23078. /**
  23079. * this function is executed by the physics engine
  23080. */
  23081. afterStep: () => void;
  23082. /**
  23083. * Legacy collision detection event support
  23084. */
  23085. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23086. /**
  23087. * event and body object due to cannon's event-based architecture.
  23088. */
  23089. onCollide: (e: {
  23090. body: any;
  23091. }) => void;
  23092. /**
  23093. * Apply a force
  23094. * @param force The force to apply
  23095. * @param contactPoint The contact point for the force
  23096. * @returns The physics imposter
  23097. */
  23098. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23099. /**
  23100. * Apply an impulse
  23101. * @param force The impulse force
  23102. * @param contactPoint The contact point for the impulse force
  23103. * @returns The physics imposter
  23104. */
  23105. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23106. /**
  23107. * A help function to create a joint
  23108. * @param otherImpostor A physics imposter used to create a joint
  23109. * @param jointType The type of joint
  23110. * @param jointData The data for the joint
  23111. * @returns The physics imposter
  23112. */
  23113. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23114. /**
  23115. * Add a joint to this impostor with a different impostor
  23116. * @param otherImpostor A physics imposter used to add a joint
  23117. * @param joint The joint to add
  23118. * @returns The physics imposter
  23119. */
  23120. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23121. /**
  23122. * Add an anchor to a cloth impostor
  23123. * @param otherImpostor rigid impostor to anchor to
  23124. * @param width ratio across width from 0 to 1
  23125. * @param height ratio up height from 0 to 1
  23126. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23127. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23128. * @returns impostor the soft imposter
  23129. */
  23130. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23131. /**
  23132. * Add a hook to a rope impostor
  23133. * @param otherImpostor rigid impostor to anchor to
  23134. * @param length ratio across rope from 0 to 1
  23135. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23136. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23137. * @returns impostor the rope imposter
  23138. */
  23139. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23140. /**
  23141. * Will keep this body still, in a sleep mode.
  23142. * @returns the physics imposter
  23143. */
  23144. sleep(): PhysicsImpostor;
  23145. /**
  23146. * Wake the body up.
  23147. * @returns The physics imposter
  23148. */
  23149. wakeUp(): PhysicsImpostor;
  23150. /**
  23151. * Clones the physics imposter
  23152. * @param newObject The physics imposter clones to this physics-enabled object
  23153. * @returns A nullable physics imposter
  23154. */
  23155. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23156. /**
  23157. * Disposes the physics imposter
  23158. */
  23159. dispose(): void;
  23160. /**
  23161. * Sets the delta position
  23162. * @param position The delta position amount
  23163. */
  23164. setDeltaPosition(position: Vector3): void;
  23165. /**
  23166. * Sets the delta rotation
  23167. * @param rotation The delta rotation amount
  23168. */
  23169. setDeltaRotation(rotation: Quaternion): void;
  23170. /**
  23171. * Gets the box size of the physics imposter and stores the result in the input parameter
  23172. * @param result Stores the box size
  23173. * @returns The physics imposter
  23174. */
  23175. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23176. /**
  23177. * Gets the radius of the physics imposter
  23178. * @returns Radius of the physics imposter
  23179. */
  23180. getRadius(): number;
  23181. /**
  23182. * Sync a bone with this impostor
  23183. * @param bone The bone to sync to the impostor.
  23184. * @param boneMesh The mesh that the bone is influencing.
  23185. * @param jointPivot The pivot of the joint / bone in local space.
  23186. * @param distToJoint Optional distance from the impostor to the joint.
  23187. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23188. */
  23189. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23190. /**
  23191. * Sync impostor to a bone
  23192. * @param bone The bone that the impostor will be synced to.
  23193. * @param boneMesh The mesh that the bone is influencing.
  23194. * @param jointPivot The pivot of the joint / bone in local space.
  23195. * @param distToJoint Optional distance from the impostor to the joint.
  23196. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23197. * @param boneAxis Optional vector3 axis the bone is aligned with
  23198. */
  23199. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23200. /**
  23201. * No-Imposter type
  23202. */
  23203. static NoImpostor: number;
  23204. /**
  23205. * Sphere-Imposter type
  23206. */
  23207. static SphereImpostor: number;
  23208. /**
  23209. * Box-Imposter type
  23210. */
  23211. static BoxImpostor: number;
  23212. /**
  23213. * Plane-Imposter type
  23214. */
  23215. static PlaneImpostor: number;
  23216. /**
  23217. * Mesh-imposter type
  23218. */
  23219. static MeshImpostor: number;
  23220. /**
  23221. * Capsule-Impostor type (Ammo.js plugin only)
  23222. */
  23223. static CapsuleImpostor: number;
  23224. /**
  23225. * Cylinder-Imposter type
  23226. */
  23227. static CylinderImpostor: number;
  23228. /**
  23229. * Particle-Imposter type
  23230. */
  23231. static ParticleImpostor: number;
  23232. /**
  23233. * Heightmap-Imposter type
  23234. */
  23235. static HeightmapImpostor: number;
  23236. /**
  23237. * ConvexHull-Impostor type (Ammo.js plugin only)
  23238. */
  23239. static ConvexHullImpostor: number;
  23240. /**
  23241. * Rope-Imposter type
  23242. */
  23243. static RopeImpostor: number;
  23244. /**
  23245. * Cloth-Imposter type
  23246. */
  23247. static ClothImpostor: number;
  23248. /**
  23249. * Softbody-Imposter type
  23250. */
  23251. static SoftbodyImpostor: number;
  23252. }
  23253. }
  23254. declare module BABYLON {
  23255. /**
  23256. * @hidden
  23257. **/
  23258. export class _CreationDataStorage {
  23259. closePath?: boolean;
  23260. closeArray?: boolean;
  23261. idx: number[];
  23262. dashSize: number;
  23263. gapSize: number;
  23264. path3D: Path3D;
  23265. pathArray: Vector3[][];
  23266. arc: number;
  23267. radius: number;
  23268. cap: number;
  23269. tessellation: number;
  23270. }
  23271. /**
  23272. * @hidden
  23273. **/
  23274. class _InstanceDataStorage {
  23275. visibleInstances: any;
  23276. batchCache: _InstancesBatch;
  23277. instancesBufferSize: number;
  23278. instancesBuffer: Nullable<Buffer>;
  23279. instancesData: Float32Array;
  23280. overridenInstanceCount: number;
  23281. isFrozen: boolean;
  23282. previousBatch: Nullable<_InstancesBatch>;
  23283. hardwareInstancedRendering: boolean;
  23284. sideOrientation: number;
  23285. }
  23286. /**
  23287. * @hidden
  23288. **/
  23289. export class _InstancesBatch {
  23290. mustReturn: boolean;
  23291. visibleInstances: Nullable<InstancedMesh[]>[];
  23292. renderSelf: boolean[];
  23293. hardwareInstancedRendering: boolean[];
  23294. }
  23295. /**
  23296. * Class used to represent renderable models
  23297. */
  23298. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23299. /**
  23300. * Mesh side orientation : usually the external or front surface
  23301. */
  23302. static readonly FRONTSIDE: number;
  23303. /**
  23304. * Mesh side orientation : usually the internal or back surface
  23305. */
  23306. static readonly BACKSIDE: number;
  23307. /**
  23308. * Mesh side orientation : both internal and external or front and back surfaces
  23309. */
  23310. static readonly DOUBLESIDE: number;
  23311. /**
  23312. * Mesh side orientation : by default, `FRONTSIDE`
  23313. */
  23314. static readonly DEFAULTSIDE: number;
  23315. /**
  23316. * Mesh cap setting : no cap
  23317. */
  23318. static readonly NO_CAP: number;
  23319. /**
  23320. * Mesh cap setting : one cap at the beginning of the mesh
  23321. */
  23322. static readonly CAP_START: number;
  23323. /**
  23324. * Mesh cap setting : one cap at the end of the mesh
  23325. */
  23326. static readonly CAP_END: number;
  23327. /**
  23328. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23329. */
  23330. static readonly CAP_ALL: number;
  23331. /**
  23332. * Mesh pattern setting : no flip or rotate
  23333. */
  23334. static readonly NO_FLIP: number;
  23335. /**
  23336. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23337. */
  23338. static readonly FLIP_TILE: number;
  23339. /**
  23340. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23341. */
  23342. static readonly ROTATE_TILE: number;
  23343. /**
  23344. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23345. */
  23346. static readonly FLIP_ROW: number;
  23347. /**
  23348. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23349. */
  23350. static readonly ROTATE_ROW: number;
  23351. /**
  23352. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23353. */
  23354. static readonly FLIP_N_ROTATE_TILE: number;
  23355. /**
  23356. * Mesh pattern setting : rotate pattern and rotate
  23357. */
  23358. static readonly FLIP_N_ROTATE_ROW: number;
  23359. /**
  23360. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23361. */
  23362. static readonly CENTER: number;
  23363. /**
  23364. * Mesh tile positioning : part tiles on left
  23365. */
  23366. static readonly LEFT: number;
  23367. /**
  23368. * Mesh tile positioning : part tiles on right
  23369. */
  23370. static readonly RIGHT: number;
  23371. /**
  23372. * Mesh tile positioning : part tiles on top
  23373. */
  23374. static readonly TOP: number;
  23375. /**
  23376. * Mesh tile positioning : part tiles on bottom
  23377. */
  23378. static readonly BOTTOM: number;
  23379. /**
  23380. * Gets the default side orientation.
  23381. * @param orientation the orientation to value to attempt to get
  23382. * @returns the default orientation
  23383. * @hidden
  23384. */
  23385. static _GetDefaultSideOrientation(orientation?: number): number;
  23386. private _internalMeshDataInfo;
  23387. /**
  23388. * An event triggered before rendering the mesh
  23389. */
  23390. readonly onBeforeRenderObservable: Observable<Mesh>;
  23391. /**
  23392. * An event triggered before binding the mesh
  23393. */
  23394. readonly onBeforeBindObservable: Observable<Mesh>;
  23395. /**
  23396. * An event triggered after rendering the mesh
  23397. */
  23398. readonly onAfterRenderObservable: Observable<Mesh>;
  23399. /**
  23400. * An event triggered before drawing the mesh
  23401. */
  23402. readonly onBeforeDrawObservable: Observable<Mesh>;
  23403. private _onBeforeDrawObserver;
  23404. /**
  23405. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23406. */
  23407. onBeforeDraw: () => void;
  23408. readonly hasInstances: boolean;
  23409. /**
  23410. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23411. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23412. */
  23413. delayLoadState: number;
  23414. /**
  23415. * Gets the list of instances created from this mesh
  23416. * it is not supposed to be modified manually.
  23417. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23418. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23419. */
  23420. instances: InstancedMesh[];
  23421. /**
  23422. * Gets the file containing delay loading data for this mesh
  23423. */
  23424. delayLoadingFile: string;
  23425. /** @hidden */
  23426. _binaryInfo: any;
  23427. /**
  23428. * User defined function used to change how LOD level selection is done
  23429. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23430. */
  23431. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23432. /**
  23433. * Gets or sets the morph target manager
  23434. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23435. */
  23436. morphTargetManager: Nullable<MorphTargetManager>;
  23437. /** @hidden */
  23438. _creationDataStorage: Nullable<_CreationDataStorage>;
  23439. /** @hidden */
  23440. _geometry: Nullable<Geometry>;
  23441. /** @hidden */
  23442. _delayInfo: Array<string>;
  23443. /** @hidden */
  23444. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23445. /** @hidden */
  23446. _instanceDataStorage: _InstanceDataStorage;
  23447. private _effectiveMaterial;
  23448. /** @hidden */
  23449. _shouldGenerateFlatShading: boolean;
  23450. /** @hidden */
  23451. _originalBuilderSideOrientation: number;
  23452. /**
  23453. * Use this property to change the original side orientation defined at construction time
  23454. */
  23455. overrideMaterialSideOrientation: Nullable<number>;
  23456. /**
  23457. * Gets the source mesh (the one used to clone this one from)
  23458. */
  23459. readonly source: Nullable<Mesh>;
  23460. /**
  23461. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23462. */
  23463. isUnIndexed: boolean;
  23464. /**
  23465. * @constructor
  23466. * @param name The value used by scene.getMeshByName() to do a lookup.
  23467. * @param scene The scene to add this mesh to.
  23468. * @param parent The parent of this mesh, if it has one
  23469. * @param source An optional Mesh from which geometry is shared, cloned.
  23470. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23471. * When false, achieved by calling a clone(), also passing False.
  23472. * This will make creation of children, recursive.
  23473. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23474. */
  23475. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23476. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23477. /**
  23478. * Gets the class name
  23479. * @returns the string "Mesh".
  23480. */
  23481. getClassName(): string;
  23482. /** @hidden */
  23483. readonly _isMesh: boolean;
  23484. /**
  23485. * Returns a description of this mesh
  23486. * @param fullDetails define if full details about this mesh must be used
  23487. * @returns a descriptive string representing this mesh
  23488. */
  23489. toString(fullDetails?: boolean): string;
  23490. /** @hidden */
  23491. _unBindEffect(): void;
  23492. /**
  23493. * Gets a boolean indicating if this mesh has LOD
  23494. */
  23495. readonly hasLODLevels: boolean;
  23496. /**
  23497. * Gets the list of MeshLODLevel associated with the current mesh
  23498. * @returns an array of MeshLODLevel
  23499. */
  23500. getLODLevels(): MeshLODLevel[];
  23501. private _sortLODLevels;
  23502. /**
  23503. * Add a mesh as LOD level triggered at the given distance.
  23504. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23505. * @param distance The distance from the center of the object to show this level
  23506. * @param mesh The mesh to be added as LOD level (can be null)
  23507. * @return This mesh (for chaining)
  23508. */
  23509. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23510. /**
  23511. * Returns the LOD level mesh at the passed distance or null if not found.
  23512. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23513. * @param distance The distance from the center of the object to show this level
  23514. * @returns a Mesh or `null`
  23515. */
  23516. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23517. /**
  23518. * Remove a mesh from the LOD array
  23519. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23520. * @param mesh defines the mesh to be removed
  23521. * @return This mesh (for chaining)
  23522. */
  23523. removeLODLevel(mesh: Mesh): Mesh;
  23524. /**
  23525. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23526. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23527. * @param camera defines the camera to use to compute distance
  23528. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23529. * @return This mesh (for chaining)
  23530. */
  23531. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23532. /**
  23533. * Gets the mesh internal Geometry object
  23534. */
  23535. readonly geometry: Nullable<Geometry>;
  23536. /**
  23537. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23538. * @returns the total number of vertices
  23539. */
  23540. getTotalVertices(): number;
  23541. /**
  23542. * Returns the content of an associated vertex buffer
  23543. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23544. * - VertexBuffer.PositionKind
  23545. * - VertexBuffer.UVKind
  23546. * - VertexBuffer.UV2Kind
  23547. * - VertexBuffer.UV3Kind
  23548. * - VertexBuffer.UV4Kind
  23549. * - VertexBuffer.UV5Kind
  23550. * - VertexBuffer.UV6Kind
  23551. * - VertexBuffer.ColorKind
  23552. * - VertexBuffer.MatricesIndicesKind
  23553. * - VertexBuffer.MatricesIndicesExtraKind
  23554. * - VertexBuffer.MatricesWeightsKind
  23555. * - VertexBuffer.MatricesWeightsExtraKind
  23556. * @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
  23557. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23558. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23559. */
  23560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23561. /**
  23562. * Returns the mesh VertexBuffer object from the requested `kind`
  23563. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23564. * - VertexBuffer.PositionKind
  23565. * - VertexBuffer.NormalKind
  23566. * - VertexBuffer.UVKind
  23567. * - VertexBuffer.UV2Kind
  23568. * - VertexBuffer.UV3Kind
  23569. * - VertexBuffer.UV4Kind
  23570. * - VertexBuffer.UV5Kind
  23571. * - VertexBuffer.UV6Kind
  23572. * - VertexBuffer.ColorKind
  23573. * - VertexBuffer.MatricesIndicesKind
  23574. * - VertexBuffer.MatricesIndicesExtraKind
  23575. * - VertexBuffer.MatricesWeightsKind
  23576. * - VertexBuffer.MatricesWeightsExtraKind
  23577. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23578. */
  23579. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23580. /**
  23581. * Tests if a specific vertex buffer is associated with this mesh
  23582. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23583. * - VertexBuffer.PositionKind
  23584. * - VertexBuffer.NormalKind
  23585. * - VertexBuffer.UVKind
  23586. * - VertexBuffer.UV2Kind
  23587. * - VertexBuffer.UV3Kind
  23588. * - VertexBuffer.UV4Kind
  23589. * - VertexBuffer.UV5Kind
  23590. * - VertexBuffer.UV6Kind
  23591. * - VertexBuffer.ColorKind
  23592. * - VertexBuffer.MatricesIndicesKind
  23593. * - VertexBuffer.MatricesIndicesExtraKind
  23594. * - VertexBuffer.MatricesWeightsKind
  23595. * - VertexBuffer.MatricesWeightsExtraKind
  23596. * @returns a boolean
  23597. */
  23598. isVerticesDataPresent(kind: string): boolean;
  23599. /**
  23600. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23601. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23602. * - VertexBuffer.PositionKind
  23603. * - VertexBuffer.UVKind
  23604. * - VertexBuffer.UV2Kind
  23605. * - VertexBuffer.UV3Kind
  23606. * - VertexBuffer.UV4Kind
  23607. * - VertexBuffer.UV5Kind
  23608. * - VertexBuffer.UV6Kind
  23609. * - VertexBuffer.ColorKind
  23610. * - VertexBuffer.MatricesIndicesKind
  23611. * - VertexBuffer.MatricesIndicesExtraKind
  23612. * - VertexBuffer.MatricesWeightsKind
  23613. * - VertexBuffer.MatricesWeightsExtraKind
  23614. * @returns a boolean
  23615. */
  23616. isVertexBufferUpdatable(kind: string): boolean;
  23617. /**
  23618. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23619. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23620. * - VertexBuffer.PositionKind
  23621. * - VertexBuffer.NormalKind
  23622. * - VertexBuffer.UVKind
  23623. * - VertexBuffer.UV2Kind
  23624. * - VertexBuffer.UV3Kind
  23625. * - VertexBuffer.UV4Kind
  23626. * - VertexBuffer.UV5Kind
  23627. * - VertexBuffer.UV6Kind
  23628. * - VertexBuffer.ColorKind
  23629. * - VertexBuffer.MatricesIndicesKind
  23630. * - VertexBuffer.MatricesIndicesExtraKind
  23631. * - VertexBuffer.MatricesWeightsKind
  23632. * - VertexBuffer.MatricesWeightsExtraKind
  23633. * @returns an array of strings
  23634. */
  23635. getVerticesDataKinds(): string[];
  23636. /**
  23637. * Returns a positive integer : the total number of indices in this mesh geometry.
  23638. * @returns the numner of indices or zero if the mesh has no geometry.
  23639. */
  23640. getTotalIndices(): number;
  23641. /**
  23642. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23643. * @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.
  23644. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23645. * @returns the indices array or an empty array if the mesh has no geometry
  23646. */
  23647. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23648. readonly isBlocked: boolean;
  23649. /**
  23650. * Determine if the current mesh is ready to be rendered
  23651. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23652. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23653. * @returns true if all associated assets are ready (material, textures, shaders)
  23654. */
  23655. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23656. /**
  23657. * 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.
  23658. */
  23659. readonly areNormalsFrozen: boolean;
  23660. /**
  23661. * 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.
  23662. * @returns the current mesh
  23663. */
  23664. freezeNormals(): Mesh;
  23665. /**
  23666. * 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
  23667. * @returns the current mesh
  23668. */
  23669. unfreezeNormals(): Mesh;
  23670. /**
  23671. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23672. */
  23673. overridenInstanceCount: number;
  23674. /** @hidden */
  23675. _preActivate(): Mesh;
  23676. /** @hidden */
  23677. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23678. /** @hidden */
  23679. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23680. /**
  23681. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23682. * This means the mesh underlying bounding box and sphere are recomputed.
  23683. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23684. * @returns the current mesh
  23685. */
  23686. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23687. /** @hidden */
  23688. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23689. /**
  23690. * This function will subdivide the mesh into multiple submeshes
  23691. * @param count defines the expected number of submeshes
  23692. */
  23693. subdivide(count: number): void;
  23694. /**
  23695. * Copy a FloatArray into a specific associated vertex buffer
  23696. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23697. * - VertexBuffer.PositionKind
  23698. * - VertexBuffer.UVKind
  23699. * - VertexBuffer.UV2Kind
  23700. * - VertexBuffer.UV3Kind
  23701. * - VertexBuffer.UV4Kind
  23702. * - VertexBuffer.UV5Kind
  23703. * - VertexBuffer.UV6Kind
  23704. * - VertexBuffer.ColorKind
  23705. * - VertexBuffer.MatricesIndicesKind
  23706. * - VertexBuffer.MatricesIndicesExtraKind
  23707. * - VertexBuffer.MatricesWeightsKind
  23708. * - VertexBuffer.MatricesWeightsExtraKind
  23709. * @param data defines the data source
  23710. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23711. * @param stride defines the data stride size (can be null)
  23712. * @returns the current mesh
  23713. */
  23714. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23715. /**
  23716. * Flags an associated vertex buffer as updatable
  23717. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23718. * - VertexBuffer.PositionKind
  23719. * - VertexBuffer.UVKind
  23720. * - VertexBuffer.UV2Kind
  23721. * - VertexBuffer.UV3Kind
  23722. * - VertexBuffer.UV4Kind
  23723. * - VertexBuffer.UV5Kind
  23724. * - VertexBuffer.UV6Kind
  23725. * - VertexBuffer.ColorKind
  23726. * - VertexBuffer.MatricesIndicesKind
  23727. * - VertexBuffer.MatricesIndicesExtraKind
  23728. * - VertexBuffer.MatricesWeightsKind
  23729. * - VertexBuffer.MatricesWeightsExtraKind
  23730. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23731. */
  23732. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23733. /**
  23734. * Sets the mesh global Vertex Buffer
  23735. * @param buffer defines the buffer to use
  23736. * @returns the current mesh
  23737. */
  23738. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23739. /**
  23740. * Update a specific associated vertex buffer
  23741. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23742. * - VertexBuffer.PositionKind
  23743. * - VertexBuffer.UVKind
  23744. * - VertexBuffer.UV2Kind
  23745. * - VertexBuffer.UV3Kind
  23746. * - VertexBuffer.UV4Kind
  23747. * - VertexBuffer.UV5Kind
  23748. * - VertexBuffer.UV6Kind
  23749. * - VertexBuffer.ColorKind
  23750. * - VertexBuffer.MatricesIndicesKind
  23751. * - VertexBuffer.MatricesIndicesExtraKind
  23752. * - VertexBuffer.MatricesWeightsKind
  23753. * - VertexBuffer.MatricesWeightsExtraKind
  23754. * @param data defines the data source
  23755. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23756. * @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)
  23757. * @returns the current mesh
  23758. */
  23759. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23760. /**
  23761. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23762. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23763. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23764. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23765. * @returns the current mesh
  23766. */
  23767. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23768. /**
  23769. * Creates a un-shared specific occurence of the geometry for the mesh.
  23770. * @returns the current mesh
  23771. */
  23772. makeGeometryUnique(): Mesh;
  23773. /**
  23774. * Set the index buffer of this mesh
  23775. * @param indices defines the source data
  23776. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23777. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23778. * @returns the current mesh
  23779. */
  23780. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23781. /**
  23782. * Update the current index buffer
  23783. * @param indices defines the source data
  23784. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23785. * @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)
  23786. * @returns the current mesh
  23787. */
  23788. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23789. /**
  23790. * Invert the geometry to move from a right handed system to a left handed one.
  23791. * @returns the current mesh
  23792. */
  23793. toLeftHanded(): Mesh;
  23794. /** @hidden */
  23795. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23796. /** @hidden */
  23797. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23798. /**
  23799. * Registers for this mesh a javascript function called just before the rendering process
  23800. * @param func defines the function to call before rendering this mesh
  23801. * @returns the current mesh
  23802. */
  23803. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23804. /**
  23805. * Disposes a previously registered javascript function called before the rendering
  23806. * @param func defines the function to remove
  23807. * @returns the current mesh
  23808. */
  23809. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23810. /**
  23811. * Registers for this mesh a javascript function called just after the rendering is complete
  23812. * @param func defines the function to call after rendering this mesh
  23813. * @returns the current mesh
  23814. */
  23815. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23816. /**
  23817. * Disposes a previously registered javascript function called after the rendering.
  23818. * @param func defines the function to remove
  23819. * @returns the current mesh
  23820. */
  23821. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23822. /** @hidden */
  23823. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23824. /** @hidden */
  23825. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23826. /** @hidden */
  23827. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23828. /** @hidden */
  23829. _rebuild(): void;
  23830. /** @hidden */
  23831. _freeze(): void;
  23832. /** @hidden */
  23833. _unFreeze(): void;
  23834. /**
  23835. * 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
  23836. * @param subMesh defines the subMesh to render
  23837. * @param enableAlphaMode defines if alpha mode can be changed
  23838. * @returns the current mesh
  23839. */
  23840. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23841. private _onBeforeDraw;
  23842. /**
  23843. * Renormalize the mesh and patch it up if there are no weights
  23844. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23845. * However in the case of zero weights then we set just a single influence to 1.
  23846. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23847. */
  23848. cleanMatrixWeights(): void;
  23849. private normalizeSkinFourWeights;
  23850. private normalizeSkinWeightsAndExtra;
  23851. /**
  23852. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23853. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23854. * the user know there was an issue with importing the mesh
  23855. * @returns a validation object with skinned, valid and report string
  23856. */
  23857. validateSkinning(): {
  23858. skinned: boolean;
  23859. valid: boolean;
  23860. report: string;
  23861. };
  23862. /** @hidden */
  23863. _checkDelayState(): Mesh;
  23864. private _queueLoad;
  23865. /**
  23866. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23867. * A mesh is in the frustum if its bounding box intersects the frustum
  23868. * @param frustumPlanes defines the frustum to test
  23869. * @returns true if the mesh is in the frustum planes
  23870. */
  23871. isInFrustum(frustumPlanes: Plane[]): boolean;
  23872. /**
  23873. * Sets the mesh material by the material or multiMaterial `id` property
  23874. * @param id is a string identifying the material or the multiMaterial
  23875. * @returns the current mesh
  23876. */
  23877. setMaterialByID(id: string): Mesh;
  23878. /**
  23879. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23880. * @returns an array of IAnimatable
  23881. */
  23882. getAnimatables(): IAnimatable[];
  23883. /**
  23884. * Modifies the mesh geometry according to the passed transformation matrix.
  23885. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23886. * The mesh normals are modified using the same transformation.
  23887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23888. * @param transform defines the transform matrix to use
  23889. * @see http://doc.babylonjs.com/resources/baking_transformations
  23890. * @returns the current mesh
  23891. */
  23892. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23893. /**
  23894. * Modifies the mesh geometry according to its own current World Matrix.
  23895. * The mesh World Matrix is then reset.
  23896. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23897. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23898. * @see http://doc.babylonjs.com/resources/baking_transformations
  23899. * @returns the current mesh
  23900. */
  23901. bakeCurrentTransformIntoVertices(): Mesh;
  23902. /** @hidden */
  23903. readonly _positions: Nullable<Vector3[]>;
  23904. /** @hidden */
  23905. _resetPointsArrayCache(): Mesh;
  23906. /** @hidden */
  23907. _generatePointsArray(): boolean;
  23908. /**
  23909. * Returns a new Mesh object generated from the current mesh properties.
  23910. * This method must not get confused with createInstance()
  23911. * @param name is a string, the name given to the new mesh
  23912. * @param newParent can be any Node object (default `null`)
  23913. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23914. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23915. * @returns a new mesh
  23916. */
  23917. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23918. /**
  23919. * Releases resources associated with this mesh.
  23920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23922. */
  23923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23924. /**
  23925. * Modifies the mesh geometry according to a displacement map.
  23926. * 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.
  23927. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23928. * @param url is a string, the URL from the image file is to be downloaded.
  23929. * @param minHeight is the lower limit of the displacement.
  23930. * @param maxHeight is the upper limit of the displacement.
  23931. * @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.
  23932. * @param uvOffset is an optional vector2 used to offset UV.
  23933. * @param uvScale is an optional vector2 used to scale UV.
  23934. * @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.
  23935. * @returns the Mesh.
  23936. */
  23937. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23938. /**
  23939. * Modifies the mesh geometry according to a displacementMap buffer.
  23940. * 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.
  23941. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23942. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23943. * @param heightMapWidth is the width of the buffer image.
  23944. * @param heightMapHeight is the height of the buffer image.
  23945. * @param minHeight is the lower limit of the displacement.
  23946. * @param maxHeight is the upper limit of the displacement.
  23947. * @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.
  23948. * @param uvOffset is an optional vector2 used to offset UV.
  23949. * @param uvScale is an optional vector2 used to scale UV.
  23950. * @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.
  23951. * @returns the Mesh.
  23952. */
  23953. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23954. /**
  23955. * Modify the mesh to get a flat shading rendering.
  23956. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23957. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23958. * @returns current mesh
  23959. */
  23960. convertToFlatShadedMesh(): Mesh;
  23961. /**
  23962. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23963. * In other words, more vertices, no more indices and a single bigger VBO.
  23964. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23965. * @returns current mesh
  23966. */
  23967. convertToUnIndexedMesh(): Mesh;
  23968. /**
  23969. * Inverses facet orientations.
  23970. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23971. * @param flipNormals will also inverts the normals
  23972. * @returns current mesh
  23973. */
  23974. flipFaces(flipNormals?: boolean): Mesh;
  23975. /**
  23976. * Increase the number of facets and hence vertices in a mesh
  23977. * Vertex normals are interpolated from existing vertex normals
  23978. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23979. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23980. */
  23981. increaseVertices(numberPerEdge: number): void;
  23982. /**
  23983. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23984. * This will undo any application of covertToFlatShadedMesh
  23985. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23986. */
  23987. forceSharedVertices(): void;
  23988. /** @hidden */
  23989. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23990. /** @hidden */
  23991. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23992. /**
  23993. * Creates a new InstancedMesh object from the mesh model.
  23994. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23995. * @param name defines the name of the new instance
  23996. * @returns a new InstancedMesh
  23997. */
  23998. createInstance(name: string): InstancedMesh;
  23999. /**
  24000. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24001. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24002. * @returns the current mesh
  24003. */
  24004. synchronizeInstances(): Mesh;
  24005. /**
  24006. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24007. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24008. * This should be used together with the simplification to avoid disappearing triangles.
  24009. * @param successCallback an optional success callback to be called after the optimization finished.
  24010. * @returns the current mesh
  24011. */
  24012. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24013. /**
  24014. * Serialize current mesh
  24015. * @param serializationObject defines the object which will receive the serialization data
  24016. */
  24017. serialize(serializationObject: any): void;
  24018. /** @hidden */
  24019. _syncGeometryWithMorphTargetManager(): void;
  24020. /** @hidden */
  24021. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24022. /**
  24023. * Returns a new Mesh object parsed from the source provided.
  24024. * @param parsedMesh is the source
  24025. * @param scene defines the hosting scene
  24026. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24027. * @returns a new Mesh
  24028. */
  24029. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24030. /**
  24031. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24032. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24033. * @param name defines the name of the mesh to create
  24034. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24035. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24036. * @param closePath creates a seam between the first and the last points of each path of the path array
  24037. * @param offset is taken in account only if the `pathArray` is containing a single path
  24038. * @param scene defines the hosting scene
  24039. * @param updatable defines if the mesh must be flagged as updatable
  24040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24041. * @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)
  24042. * @returns a new Mesh
  24043. */
  24044. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24045. /**
  24046. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24047. * @param name defines the name of the mesh to create
  24048. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24049. * @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
  24050. * @param scene defines the hosting scene
  24051. * @param updatable defines if the mesh must be flagged as updatable
  24052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24053. * @returns a new Mesh
  24054. */
  24055. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24056. /**
  24057. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24058. * @param name defines the name of the mesh to create
  24059. * @param size sets the size (float) of each box side (default 1)
  24060. * @param scene defines the hosting scene
  24061. * @param updatable defines if the mesh must be flagged as updatable
  24062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24063. * @returns a new Mesh
  24064. */
  24065. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24066. /**
  24067. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24068. * @param name defines the name of the mesh to create
  24069. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24070. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24071. * @param scene defines the hosting scene
  24072. * @param updatable defines if the mesh must be flagged as updatable
  24073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24074. * @returns a new Mesh
  24075. */
  24076. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24077. /**
  24078. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24079. * @param name defines the name of the mesh to create
  24080. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24081. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24082. * @param scene defines the hosting scene
  24083. * @returns a new Mesh
  24084. */
  24085. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24086. /**
  24087. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24088. * @param name defines the name of the mesh to create
  24089. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24090. * @param diameterTop set the top cap diameter (floats, default 1)
  24091. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24092. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24093. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24094. * @param scene defines the hosting scene
  24095. * @param updatable defines if the mesh must be flagged as updatable
  24096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24097. * @returns a new Mesh
  24098. */
  24099. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24100. /**
  24101. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24102. * @param name defines the name of the mesh to create
  24103. * @param diameter sets the diameter size (float) of the torus (default 1)
  24104. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24105. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24106. * @param scene defines the hosting scene
  24107. * @param updatable defines if the mesh must be flagged as updatable
  24108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24109. * @returns a new Mesh
  24110. */
  24111. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24112. /**
  24113. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24114. * @param name defines the name of the mesh to create
  24115. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24116. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24117. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24118. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24119. * @param p the number of windings on X axis (positive integers, default 2)
  24120. * @param q the number of windings on Y axis (positive integers, default 3)
  24121. * @param scene defines the hosting scene
  24122. * @param updatable defines if the mesh must be flagged as updatable
  24123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24124. * @returns a new Mesh
  24125. */
  24126. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24127. /**
  24128. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24129. * @param name defines the name of the mesh to create
  24130. * @param points is an array successive Vector3
  24131. * @param scene defines the hosting scene
  24132. * @param updatable defines if the mesh must be flagged as updatable
  24133. * @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).
  24134. * @returns a new Mesh
  24135. */
  24136. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24137. /**
  24138. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24139. * @param name defines the name of the mesh to create
  24140. * @param points is an array successive Vector3
  24141. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24142. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24143. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24144. * @param scene defines the hosting scene
  24145. * @param updatable defines if the mesh must be flagged as updatable
  24146. * @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)
  24147. * @returns a new Mesh
  24148. */
  24149. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24150. /**
  24151. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24152. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24153. * 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.
  24154. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24155. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24156. * Remember you can only change the shape positions, not their number when updating a polygon.
  24157. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24158. * @param name defines the name of the mesh to create
  24159. * @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
  24160. * @param scene defines the hosting scene
  24161. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24162. * @param updatable defines if the mesh must be flagged as updatable
  24163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24164. * @param earcutInjection can be used to inject your own earcut reference
  24165. * @returns a new Mesh
  24166. */
  24167. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24168. /**
  24169. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24170. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24171. * @param name defines the name of the mesh to create
  24172. * @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
  24173. * @param depth defines the height of extrusion
  24174. * @param scene defines the hosting scene
  24175. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24176. * @param updatable defines if the mesh must be flagged as updatable
  24177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24178. * @param earcutInjection can be used to inject your own earcut reference
  24179. * @returns a new Mesh
  24180. */
  24181. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24182. /**
  24183. * Creates an extruded shape mesh.
  24184. * 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
  24185. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24186. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24187. * @param name defines the name of the mesh to create
  24188. * @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
  24189. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24190. * @param scale is the value to scale the shape
  24191. * @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
  24192. * @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
  24193. * @param scene defines the hosting scene
  24194. * @param updatable defines if the mesh must be flagged as updatable
  24195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24196. * @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)
  24197. * @returns a new Mesh
  24198. */
  24199. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24200. /**
  24201. * Creates an custom extruded shape mesh.
  24202. * The custom extrusion is a parametric shape.
  24203. * It has no predefined shape. Its final shape will depend on the input parameters.
  24204. * Please consider using the same method from the MeshBuilder class instead
  24205. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24206. * @param name defines the name of the mesh to create
  24207. * @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
  24208. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24209. * @param scaleFunction is a custom Javascript function called on each path point
  24210. * @param rotationFunction is a custom Javascript function called on each path point
  24211. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24212. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24213. * @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
  24214. * @param scene defines the hosting scene
  24215. * @param updatable defines if the mesh must be flagged as updatable
  24216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24217. * @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)
  24218. * @returns a new Mesh
  24219. */
  24220. 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;
  24221. /**
  24222. * Creates lathe mesh.
  24223. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24224. * Please consider using the same method from the MeshBuilder class instead
  24225. * @param name defines the name of the mesh to create
  24226. * @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
  24227. * @param radius is the radius value of the lathe
  24228. * @param tessellation is the side number of the lathe.
  24229. * @param scene defines the hosting scene
  24230. * @param updatable defines if the mesh must be flagged as updatable
  24231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24232. * @returns a new Mesh
  24233. */
  24234. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24235. /**
  24236. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24237. * @param name defines the name of the mesh to create
  24238. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24239. * @param scene defines the hosting scene
  24240. * @param updatable defines if the mesh must be flagged as updatable
  24241. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24242. * @returns a new Mesh
  24243. */
  24244. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24245. /**
  24246. * Creates a ground mesh.
  24247. * Please consider using the same method from the MeshBuilder class instead
  24248. * @param name defines the name of the mesh to create
  24249. * @param width set the width of the ground
  24250. * @param height set the height of the ground
  24251. * @param subdivisions sets the number of subdivisions per side
  24252. * @param scene defines the hosting scene
  24253. * @param updatable defines if the mesh must be flagged as updatable
  24254. * @returns a new Mesh
  24255. */
  24256. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24257. /**
  24258. * Creates a tiled ground mesh.
  24259. * Please consider using the same method from the MeshBuilder class instead
  24260. * @param name defines the name of the mesh to create
  24261. * @param xmin set the ground minimum X coordinate
  24262. * @param zmin set the ground minimum Y coordinate
  24263. * @param xmax set the ground maximum X coordinate
  24264. * @param zmax set the ground maximum Z coordinate
  24265. * @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
  24266. * @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
  24267. * @param scene defines the hosting scene
  24268. * @param updatable defines if the mesh must be flagged as updatable
  24269. * @returns a new Mesh
  24270. */
  24271. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24272. w: number;
  24273. h: number;
  24274. }, precision: {
  24275. w: number;
  24276. h: number;
  24277. }, scene: Scene, updatable?: boolean): Mesh;
  24278. /**
  24279. * Creates a ground mesh from a height map.
  24280. * Please consider using the same method from the MeshBuilder class instead
  24281. * @see http://doc.babylonjs.com/babylon101/height_map
  24282. * @param name defines the name of the mesh to create
  24283. * @param url sets the URL of the height map image resource
  24284. * @param width set the ground width size
  24285. * @param height set the ground height size
  24286. * @param subdivisions sets the number of subdivision per side
  24287. * @param minHeight is the minimum altitude on the ground
  24288. * @param maxHeight is the maximum altitude on the ground
  24289. * @param scene defines the hosting scene
  24290. * @param updatable defines if the mesh must be flagged as updatable
  24291. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24292. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24293. * @returns a new Mesh
  24294. */
  24295. 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;
  24296. /**
  24297. * Creates a tube mesh.
  24298. * The tube is a parametric shape.
  24299. * It has no predefined shape. Its final shape will depend on the input parameters.
  24300. * Please consider using the same method from the MeshBuilder class instead
  24301. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24302. * @param name defines the name of the mesh to create
  24303. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24304. * @param radius sets the tube radius size
  24305. * @param tessellation is the number of sides on the tubular surface
  24306. * @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
  24307. * @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
  24308. * @param scene defines the hosting scene
  24309. * @param updatable defines if the mesh must be flagged as updatable
  24310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24311. * @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)
  24312. * @returns a new Mesh
  24313. */
  24314. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24315. (i: number, distance: number): number;
  24316. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24317. /**
  24318. * Creates a polyhedron mesh.
  24319. * Please consider using the same method from the MeshBuilder class instead.
  24320. * * 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
  24321. * * The parameter `size` (positive float, default 1) sets the polygon size
  24322. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24323. * * 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`
  24324. * * 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
  24325. * * 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)`)
  24326. * * 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
  24327. * * 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
  24328. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24329. * * 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
  24330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24331. * @param name defines the name of the mesh to create
  24332. * @param options defines the options used to create the mesh
  24333. * @param scene defines the hosting scene
  24334. * @returns a new Mesh
  24335. */
  24336. static CreatePolyhedron(name: string, options: {
  24337. type?: number;
  24338. size?: number;
  24339. sizeX?: number;
  24340. sizeY?: number;
  24341. sizeZ?: number;
  24342. custom?: any;
  24343. faceUV?: Vector4[];
  24344. faceColors?: Color4[];
  24345. updatable?: boolean;
  24346. sideOrientation?: number;
  24347. }, scene: Scene): Mesh;
  24348. /**
  24349. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24350. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24351. * * 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`)
  24352. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24353. * * 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
  24354. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24355. * * 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
  24356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24357. * @param name defines the name of the mesh
  24358. * @param options defines the options used to create the mesh
  24359. * @param scene defines the hosting scene
  24360. * @returns a new Mesh
  24361. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24362. */
  24363. static CreateIcoSphere(name: string, options: {
  24364. radius?: number;
  24365. flat?: boolean;
  24366. subdivisions?: number;
  24367. sideOrientation?: number;
  24368. updatable?: boolean;
  24369. }, scene: Scene): Mesh;
  24370. /**
  24371. * Creates a decal mesh.
  24372. * Please consider using the same method from the MeshBuilder class instead.
  24373. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24374. * @param name defines the name of the mesh
  24375. * @param sourceMesh defines the mesh receiving the decal
  24376. * @param position sets the position of the decal in world coordinates
  24377. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24378. * @param size sets the decal scaling
  24379. * @param angle sets the angle to rotate the decal
  24380. * @returns a new Mesh
  24381. */
  24382. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24383. /**
  24384. * Prepare internal position array for software CPU skinning
  24385. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24386. */
  24387. setPositionsForCPUSkinning(): Float32Array;
  24388. /**
  24389. * Prepare internal normal array for software CPU skinning
  24390. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24391. */
  24392. setNormalsForCPUSkinning(): Float32Array;
  24393. /**
  24394. * Updates the vertex buffer by applying transformation from the bones
  24395. * @param skeleton defines the skeleton to apply to current mesh
  24396. * @returns the current mesh
  24397. */
  24398. applySkeleton(skeleton: Skeleton): Mesh;
  24399. /**
  24400. * 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
  24401. * @param meshes defines the list of meshes to scan
  24402. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24403. */
  24404. static MinMax(meshes: AbstractMesh[]): {
  24405. min: Vector3;
  24406. max: Vector3;
  24407. };
  24408. /**
  24409. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24410. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24411. * @returns a vector3
  24412. */
  24413. static Center(meshesOrMinMaxVector: {
  24414. min: Vector3;
  24415. max: Vector3;
  24416. } | AbstractMesh[]): Vector3;
  24417. /**
  24418. * Merge the array of meshes into a single mesh for performance reasons.
  24419. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24420. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24421. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24422. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24423. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24424. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24425. * @returns a new mesh
  24426. */
  24427. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24428. /** @hidden */
  24429. addInstance(instance: InstancedMesh): void;
  24430. /** @hidden */
  24431. removeInstance(instance: InstancedMesh): void;
  24432. }
  24433. }
  24434. declare module BABYLON {
  24435. /**
  24436. * This is the base class of all the camera used in the application.
  24437. * @see http://doc.babylonjs.com/features/cameras
  24438. */
  24439. export class Camera extends Node {
  24440. /** @hidden */
  24441. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24442. /**
  24443. * This is the default projection mode used by the cameras.
  24444. * It helps recreating a feeling of perspective and better appreciate depth.
  24445. * This is the best way to simulate real life cameras.
  24446. */
  24447. static readonly PERSPECTIVE_CAMERA: number;
  24448. /**
  24449. * This helps creating camera with an orthographic mode.
  24450. * 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.
  24451. */
  24452. static readonly ORTHOGRAPHIC_CAMERA: number;
  24453. /**
  24454. * This is the default FOV mode for perspective cameras.
  24455. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24456. */
  24457. static readonly FOVMODE_VERTICAL_FIXED: number;
  24458. /**
  24459. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24460. */
  24461. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24462. /**
  24463. * This specifies ther is no need for a camera rig.
  24464. * Basically only one eye is rendered corresponding to the camera.
  24465. */
  24466. static readonly RIG_MODE_NONE: number;
  24467. /**
  24468. * Simulates a camera Rig with one blue eye and one red eye.
  24469. * This can be use with 3d blue and red glasses.
  24470. */
  24471. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24472. /**
  24473. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24474. */
  24475. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24476. /**
  24477. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24478. */
  24479. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24480. /**
  24481. * Defines that both eyes of the camera will be rendered over under each other.
  24482. */
  24483. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24484. /**
  24485. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24486. */
  24487. static readonly RIG_MODE_VR: number;
  24488. /**
  24489. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24490. */
  24491. static readonly RIG_MODE_WEBVR: number;
  24492. /**
  24493. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24494. */
  24495. static readonly RIG_MODE_CUSTOM: number;
  24496. /**
  24497. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24498. */
  24499. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24500. /**
  24501. * Define the input manager associated with the camera.
  24502. */
  24503. inputs: CameraInputsManager<Camera>;
  24504. /** @hidden */
  24505. _position: Vector3;
  24506. /**
  24507. * Define the current local position of the camera in the scene
  24508. */
  24509. position: Vector3;
  24510. /**
  24511. * The vector the camera should consider as up.
  24512. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24513. */
  24514. upVector: Vector3;
  24515. /**
  24516. * Define the current limit on the left side for an orthographic camera
  24517. * In scene unit
  24518. */
  24519. orthoLeft: Nullable<number>;
  24520. /**
  24521. * Define the current limit on the right side for an orthographic camera
  24522. * In scene unit
  24523. */
  24524. orthoRight: Nullable<number>;
  24525. /**
  24526. * Define the current limit on the bottom side for an orthographic camera
  24527. * In scene unit
  24528. */
  24529. orthoBottom: Nullable<number>;
  24530. /**
  24531. * Define the current limit on the top side for an orthographic camera
  24532. * In scene unit
  24533. */
  24534. orthoTop: Nullable<number>;
  24535. /**
  24536. * Field Of View is set in Radians. (default is 0.8)
  24537. */
  24538. fov: number;
  24539. /**
  24540. * Define the minimum distance the camera can see from.
  24541. * This is important to note that the depth buffer are not infinite and the closer it starts
  24542. * the more your scene might encounter depth fighting issue.
  24543. */
  24544. minZ: number;
  24545. /**
  24546. * Define the maximum distance the camera can see to.
  24547. * This is important to note that the depth buffer are not infinite and the further it end
  24548. * the more your scene might encounter depth fighting issue.
  24549. */
  24550. maxZ: number;
  24551. /**
  24552. * Define the default inertia of the camera.
  24553. * This helps giving a smooth feeling to the camera movement.
  24554. */
  24555. inertia: number;
  24556. /**
  24557. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24558. */
  24559. mode: number;
  24560. /**
  24561. * Define wether the camera is intermediate.
  24562. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24563. */
  24564. isIntermediate: boolean;
  24565. /**
  24566. * Define the viewport of the camera.
  24567. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24568. */
  24569. viewport: Viewport;
  24570. /**
  24571. * Restricts the camera to viewing objects with the same layerMask.
  24572. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24573. */
  24574. layerMask: number;
  24575. /**
  24576. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24577. */
  24578. fovMode: number;
  24579. /**
  24580. * Rig mode of the camera.
  24581. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24582. * This is normally controlled byt the camera themselves as internal use.
  24583. */
  24584. cameraRigMode: number;
  24585. /**
  24586. * Defines the distance between both "eyes" in case of a RIG
  24587. */
  24588. interaxialDistance: number;
  24589. /**
  24590. * Defines if stereoscopic rendering is done side by side or over under.
  24591. */
  24592. isStereoscopicSideBySide: boolean;
  24593. /**
  24594. * 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
  24595. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24596. * else in the scene. (Eg. security camera)
  24597. *
  24598. * 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)
  24599. */
  24600. customRenderTargets: RenderTargetTexture[];
  24601. /**
  24602. * When set, the camera will render to this render target instead of the default canvas
  24603. *
  24604. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24605. */
  24606. outputRenderTarget: Nullable<RenderTargetTexture>;
  24607. /**
  24608. * Observable triggered when the camera view matrix has changed.
  24609. */
  24610. onViewMatrixChangedObservable: Observable<Camera>;
  24611. /**
  24612. * Observable triggered when the camera Projection matrix has changed.
  24613. */
  24614. onProjectionMatrixChangedObservable: Observable<Camera>;
  24615. /**
  24616. * Observable triggered when the inputs have been processed.
  24617. */
  24618. onAfterCheckInputsObservable: Observable<Camera>;
  24619. /**
  24620. * Observable triggered when reset has been called and applied to the camera.
  24621. */
  24622. onRestoreStateObservable: Observable<Camera>;
  24623. /** @hidden */
  24624. _cameraRigParams: any;
  24625. /** @hidden */
  24626. _rigCameras: Camera[];
  24627. /** @hidden */
  24628. _rigPostProcess: Nullable<PostProcess>;
  24629. protected _webvrViewMatrix: Matrix;
  24630. /** @hidden */
  24631. _skipRendering: boolean;
  24632. /** @hidden */
  24633. _projectionMatrix: Matrix;
  24634. /** @hidden */
  24635. _postProcesses: Nullable<PostProcess>[];
  24636. /** @hidden */
  24637. _activeMeshes: SmartArray<AbstractMesh>;
  24638. protected _globalPosition: Vector3;
  24639. /** @hidden */
  24640. _computedViewMatrix: Matrix;
  24641. private _doNotComputeProjectionMatrix;
  24642. private _transformMatrix;
  24643. private _frustumPlanes;
  24644. private _refreshFrustumPlanes;
  24645. private _storedFov;
  24646. private _stateStored;
  24647. /**
  24648. * Instantiates a new camera object.
  24649. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24650. * @see http://doc.babylonjs.com/features/cameras
  24651. * @param name Defines the name of the camera in the scene
  24652. * @param position Defines the position of the camera
  24653. * @param scene Defines the scene the camera belongs too
  24654. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24655. */
  24656. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24657. /**
  24658. * Store current camera state (fov, position, etc..)
  24659. * @returns the camera
  24660. */
  24661. storeState(): Camera;
  24662. /**
  24663. * Restores the camera state values if it has been stored. You must call storeState() first
  24664. */
  24665. protected _restoreStateValues(): boolean;
  24666. /**
  24667. * Restored camera state. You must call storeState() first.
  24668. * @returns true if restored and false otherwise
  24669. */
  24670. restoreState(): boolean;
  24671. /**
  24672. * Gets the class name of the camera.
  24673. * @returns the class name
  24674. */
  24675. getClassName(): string;
  24676. /** @hidden */
  24677. readonly _isCamera: boolean;
  24678. /**
  24679. * Gets a string representation of the camera useful for debug purpose.
  24680. * @param fullDetails Defines that a more verboe level of logging is required
  24681. * @returns the string representation
  24682. */
  24683. toString(fullDetails?: boolean): string;
  24684. /**
  24685. * Gets the current world space position of the camera.
  24686. */
  24687. readonly globalPosition: Vector3;
  24688. /**
  24689. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24690. * @returns the active meshe list
  24691. */
  24692. getActiveMeshes(): SmartArray<AbstractMesh>;
  24693. /**
  24694. * Check wether a mesh is part of the current active mesh list of the camera
  24695. * @param mesh Defines the mesh to check
  24696. * @returns true if active, false otherwise
  24697. */
  24698. isActiveMesh(mesh: Mesh): boolean;
  24699. /**
  24700. * Is this camera ready to be used/rendered
  24701. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24702. * @return true if the camera is ready
  24703. */
  24704. isReady(completeCheck?: boolean): boolean;
  24705. /** @hidden */
  24706. _initCache(): void;
  24707. /** @hidden */
  24708. _updateCache(ignoreParentClass?: boolean): void;
  24709. /** @hidden */
  24710. _isSynchronized(): boolean;
  24711. /** @hidden */
  24712. _isSynchronizedViewMatrix(): boolean;
  24713. /** @hidden */
  24714. _isSynchronizedProjectionMatrix(): boolean;
  24715. /**
  24716. * Attach the input controls to a specific dom element to get the input from.
  24717. * @param element Defines the element the controls should be listened from
  24718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24719. */
  24720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24721. /**
  24722. * Detach the current controls from the specified dom element.
  24723. * @param element Defines the element to stop listening the inputs from
  24724. */
  24725. detachControl(element: HTMLElement): void;
  24726. /**
  24727. * Update the camera state according to the different inputs gathered during the frame.
  24728. */
  24729. update(): void;
  24730. /** @hidden */
  24731. _checkInputs(): void;
  24732. /** @hidden */
  24733. readonly rigCameras: Camera[];
  24734. /**
  24735. * Gets the post process used by the rig cameras
  24736. */
  24737. readonly rigPostProcess: Nullable<PostProcess>;
  24738. /**
  24739. * Internal, gets the first post proces.
  24740. * @returns the first post process to be run on this camera.
  24741. */
  24742. _getFirstPostProcess(): Nullable<PostProcess>;
  24743. private _cascadePostProcessesToRigCams;
  24744. /**
  24745. * Attach a post process to the camera.
  24746. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24747. * @param postProcess The post process to attach to the camera
  24748. * @param insertAt The position of the post process in case several of them are in use in the scene
  24749. * @returns the position the post process has been inserted at
  24750. */
  24751. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24752. /**
  24753. * Detach a post process to the camera.
  24754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24755. * @param postProcess The post process to detach from the camera
  24756. */
  24757. detachPostProcess(postProcess: PostProcess): void;
  24758. /**
  24759. * Gets the current world matrix of the camera
  24760. */
  24761. getWorldMatrix(): Matrix;
  24762. /** @hidden */
  24763. _getViewMatrix(): Matrix;
  24764. /**
  24765. * Gets the current view matrix of the camera.
  24766. * @param force forces the camera to recompute the matrix without looking at the cached state
  24767. * @returns the view matrix
  24768. */
  24769. getViewMatrix(force?: boolean): Matrix;
  24770. /**
  24771. * Freeze the projection matrix.
  24772. * It will prevent the cache check of the camera projection compute and can speed up perf
  24773. * if no parameter of the camera are meant to change
  24774. * @param projection Defines manually a projection if necessary
  24775. */
  24776. freezeProjectionMatrix(projection?: Matrix): void;
  24777. /**
  24778. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24779. */
  24780. unfreezeProjectionMatrix(): void;
  24781. /**
  24782. * Gets the current projection matrix of the camera.
  24783. * @param force forces the camera to recompute the matrix without looking at the cached state
  24784. * @returns the projection matrix
  24785. */
  24786. getProjectionMatrix(force?: boolean): Matrix;
  24787. /**
  24788. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24789. * @returns a Matrix
  24790. */
  24791. getTransformationMatrix(): Matrix;
  24792. private _updateFrustumPlanes;
  24793. /**
  24794. * Checks if a cullable object (mesh...) is in the camera frustum
  24795. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24796. * @param target The object to check
  24797. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24798. * @returns true if the object is in frustum otherwise false
  24799. */
  24800. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24801. /**
  24802. * Checks if a cullable object (mesh...) is in the camera frustum
  24803. * Unlike isInFrustum this cheks the full bounding box
  24804. * @param target The object to check
  24805. * @returns true if the object is in frustum otherwise false
  24806. */
  24807. isCompletelyInFrustum(target: ICullable): boolean;
  24808. /**
  24809. * Gets a ray in the forward direction from the camera.
  24810. * @param length Defines the length of the ray to create
  24811. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24812. * @param origin Defines the start point of the ray which defaults to the camera position
  24813. * @returns the forward ray
  24814. */
  24815. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24816. /**
  24817. * Releases resources associated with this node.
  24818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24820. */
  24821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24822. /** @hidden */
  24823. _isLeftCamera: boolean;
  24824. /**
  24825. * Gets the left camera of a rig setup in case of Rigged Camera
  24826. */
  24827. readonly isLeftCamera: boolean;
  24828. /** @hidden */
  24829. _isRightCamera: boolean;
  24830. /**
  24831. * Gets the right camera of a rig setup in case of Rigged Camera
  24832. */
  24833. readonly isRightCamera: boolean;
  24834. /**
  24835. * Gets the left camera of a rig setup in case of Rigged Camera
  24836. */
  24837. readonly leftCamera: Nullable<FreeCamera>;
  24838. /**
  24839. * Gets the right camera of a rig setup in case of Rigged Camera
  24840. */
  24841. readonly rightCamera: Nullable<FreeCamera>;
  24842. /**
  24843. * Gets the left camera target of a rig setup in case of Rigged Camera
  24844. * @returns the target position
  24845. */
  24846. getLeftTarget(): Nullable<Vector3>;
  24847. /**
  24848. * Gets the right camera target of a rig setup in case of Rigged Camera
  24849. * @returns the target position
  24850. */
  24851. getRightTarget(): Nullable<Vector3>;
  24852. /**
  24853. * @hidden
  24854. */
  24855. setCameraRigMode(mode: number, rigParams: any): void;
  24856. /** @hidden */
  24857. static _setStereoscopicRigMode(camera: Camera): void;
  24858. /** @hidden */
  24859. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24860. /** @hidden */
  24861. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24862. /** @hidden */
  24863. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24864. /** @hidden */
  24865. _getVRProjectionMatrix(): Matrix;
  24866. protected _updateCameraRotationMatrix(): void;
  24867. protected _updateWebVRCameraRotationMatrix(): void;
  24868. /**
  24869. * This function MUST be overwritten by the different WebVR cameras available.
  24870. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24871. * @hidden
  24872. */
  24873. _getWebVRProjectionMatrix(): Matrix;
  24874. /**
  24875. * This function MUST be overwritten by the different WebVR cameras available.
  24876. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24877. * @hidden
  24878. */
  24879. _getWebVRViewMatrix(): Matrix;
  24880. /** @hidden */
  24881. setCameraRigParameter(name: string, value: any): void;
  24882. /**
  24883. * needs to be overridden by children so sub has required properties to be copied
  24884. * @hidden
  24885. */
  24886. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24887. /**
  24888. * May need to be overridden by children
  24889. * @hidden
  24890. */
  24891. _updateRigCameras(): void;
  24892. /** @hidden */
  24893. _setupInputs(): void;
  24894. /**
  24895. * Serialiaze the camera setup to a json represention
  24896. * @returns the JSON representation
  24897. */
  24898. serialize(): any;
  24899. /**
  24900. * Clones the current camera.
  24901. * @param name The cloned camera name
  24902. * @returns the cloned camera
  24903. */
  24904. clone(name: string): Camera;
  24905. /**
  24906. * Gets the direction of the camera relative to a given local axis.
  24907. * @param localAxis Defines the reference axis to provide a relative direction.
  24908. * @return the direction
  24909. */
  24910. getDirection(localAxis: Vector3): Vector3;
  24911. /**
  24912. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24913. * @param localAxis Defines the reference axis to provide a relative direction.
  24914. * @param result Defines the vector to store the result in
  24915. */
  24916. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24917. /**
  24918. * Gets a camera constructor for a given camera type
  24919. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24920. * @param name The name of the camera the result will be able to instantiate
  24921. * @param scene The scene the result will construct the camera in
  24922. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24923. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24924. * @returns a factory method to construc the camera
  24925. */
  24926. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24927. /**
  24928. * Compute the world matrix of the camera.
  24929. * @returns the camera workd matrix
  24930. */
  24931. computeWorldMatrix(): Matrix;
  24932. /**
  24933. * Parse a JSON and creates the camera from the parsed information
  24934. * @param parsedCamera The JSON to parse
  24935. * @param scene The scene to instantiate the camera in
  24936. * @returns the newly constructed camera
  24937. */
  24938. static Parse(parsedCamera: any, scene: Scene): Camera;
  24939. }
  24940. }
  24941. declare module BABYLON {
  24942. /**
  24943. * Class containing static functions to help procedurally build meshes
  24944. */
  24945. export class DiscBuilder {
  24946. /**
  24947. * Creates a plane polygonal mesh. By default, this is a disc
  24948. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24949. * * 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
  24950. * * 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
  24951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24952. * * 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
  24953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24954. * @param name defines the name of the mesh
  24955. * @param options defines the options used to create the mesh
  24956. * @param scene defines the hosting scene
  24957. * @returns the plane polygonal mesh
  24958. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24959. */
  24960. static CreateDisc(name: string, options: {
  24961. radius?: number;
  24962. tessellation?: number;
  24963. arc?: number;
  24964. updatable?: boolean;
  24965. sideOrientation?: number;
  24966. frontUVs?: Vector4;
  24967. backUVs?: Vector4;
  24968. }, scene?: Nullable<Scene>): Mesh;
  24969. }
  24970. }
  24971. declare module BABYLON {
  24972. /**
  24973. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24974. *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.
  24975. * The SPS is also a particle system. It provides some methods to manage the particles.
  24976. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24977. *
  24978. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24979. */
  24980. export class SolidParticleSystem implements IDisposable {
  24981. /**
  24982. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24983. * Example : var p = SPS.particles[i];
  24984. */
  24985. particles: SolidParticle[];
  24986. /**
  24987. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24988. */
  24989. nbParticles: number;
  24990. /**
  24991. * If the particles must ever face the camera (default false). Useful for planar particles.
  24992. */
  24993. billboard: boolean;
  24994. /**
  24995. * Recompute normals when adding a shape
  24996. */
  24997. recomputeNormals: boolean;
  24998. /**
  24999. * This a counter ofr your own usage. It's not set by any SPS functions.
  25000. */
  25001. counter: number;
  25002. /**
  25003. * The SPS name. This name is also given to the underlying mesh.
  25004. */
  25005. name: string;
  25006. /**
  25007. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25008. */
  25009. mesh: Mesh;
  25010. /**
  25011. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25012. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25013. */
  25014. vars: any;
  25015. /**
  25016. * This array is populated when the SPS is set as 'pickable'.
  25017. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25018. * Each element of this array is an object `{idx: int, faceId: int}`.
  25019. * `idx` is the picked particle index in the `SPS.particles` array
  25020. * `faceId` is the picked face index counted within this particle.
  25021. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25022. */
  25023. pickedParticles: {
  25024. idx: number;
  25025. faceId: number;
  25026. }[];
  25027. /**
  25028. * This array is populated when `enableDepthSort` is set to true.
  25029. * Each element of this array is an instance of the class DepthSortedParticle.
  25030. */
  25031. depthSortedParticles: DepthSortedParticle[];
  25032. /**
  25033. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25034. * @hidden
  25035. */
  25036. _bSphereOnly: boolean;
  25037. /**
  25038. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25039. * @hidden
  25040. */
  25041. _bSphereRadiusFactor: number;
  25042. private _scene;
  25043. private _positions;
  25044. private _indices;
  25045. private _normals;
  25046. private _colors;
  25047. private _uvs;
  25048. private _indices32;
  25049. private _positions32;
  25050. private _normals32;
  25051. private _fixedNormal32;
  25052. private _colors32;
  25053. private _uvs32;
  25054. private _index;
  25055. private _updatable;
  25056. private _pickable;
  25057. private _isVisibilityBoxLocked;
  25058. private _alwaysVisible;
  25059. private _depthSort;
  25060. private _shapeCounter;
  25061. private _copy;
  25062. private _color;
  25063. private _computeParticleColor;
  25064. private _computeParticleTexture;
  25065. private _computeParticleRotation;
  25066. private _computeParticleVertex;
  25067. private _computeBoundingBox;
  25068. private _depthSortParticles;
  25069. private _camera;
  25070. private _mustUnrotateFixedNormals;
  25071. private _particlesIntersect;
  25072. private _needs32Bits;
  25073. /**
  25074. * Creates a SPS (Solid Particle System) object.
  25075. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25076. * @param scene (Scene) is the scene in which the SPS is added.
  25077. * @param options defines the options of the sps e.g.
  25078. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25079. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25080. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25081. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25082. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25083. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25084. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25085. */
  25086. constructor(name: string, scene: Scene, options?: {
  25087. updatable?: boolean;
  25088. isPickable?: boolean;
  25089. enableDepthSort?: boolean;
  25090. particleIntersection?: boolean;
  25091. boundingSphereOnly?: boolean;
  25092. bSphereRadiusFactor?: number;
  25093. });
  25094. /**
  25095. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25096. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25097. * @returns the created mesh
  25098. */
  25099. buildMesh(): Mesh;
  25100. /**
  25101. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25102. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25103. * Thus the particles generated from `digest()` have their property `position` set yet.
  25104. * @param mesh ( Mesh ) is the mesh to be digested
  25105. * @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
  25106. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25107. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25108. * @returns the current SPS
  25109. */
  25110. digest(mesh: Mesh, options?: {
  25111. facetNb?: number;
  25112. number?: number;
  25113. delta?: number;
  25114. }): SolidParticleSystem;
  25115. private _unrotateFixedNormals;
  25116. private _resetCopy;
  25117. private _meshBuilder;
  25118. private _posToShape;
  25119. private _uvsToShapeUV;
  25120. private _addParticle;
  25121. /**
  25122. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25123. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25124. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25125. * @param nb (positive integer) the number of particles to be created from this model
  25126. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25127. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25128. * @returns the number of shapes in the system
  25129. */
  25130. addShape(mesh: Mesh, nb: number, options?: {
  25131. positionFunction?: any;
  25132. vertexFunction?: any;
  25133. }): number;
  25134. private _rebuildParticle;
  25135. /**
  25136. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25137. * @returns the SPS.
  25138. */
  25139. rebuildMesh(): SolidParticleSystem;
  25140. /**
  25141. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25142. * This method calls `updateParticle()` for each particle of the SPS.
  25143. * For an animated SPS, it is usually called within the render loop.
  25144. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25145. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25146. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25147. * @returns the SPS.
  25148. */
  25149. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25150. /**
  25151. * Disposes the SPS.
  25152. */
  25153. dispose(): void;
  25154. /**
  25155. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25157. * @returns the SPS.
  25158. */
  25159. refreshVisibleSize(): SolidParticleSystem;
  25160. /**
  25161. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25162. * @param size the size (float) of the visibility box
  25163. * note : this doesn't lock the SPS mesh bounding box.
  25164. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25165. */
  25166. setVisibilityBox(size: number): void;
  25167. /**
  25168. * Gets whether the SPS as always visible or not
  25169. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25170. */
  25171. /**
  25172. * Sets the SPS as always visible or not
  25173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25174. */
  25175. isAlwaysVisible: boolean;
  25176. /**
  25177. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25178. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25179. */
  25180. /**
  25181. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25183. */
  25184. isVisibilityBoxLocked: boolean;
  25185. /**
  25186. * Tells to `setParticles()` to compute the particle rotations or not.
  25187. * Default value : true. The SPS is faster when it's set to false.
  25188. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25189. */
  25190. /**
  25191. * Gets if `setParticles()` computes the particle rotations or not.
  25192. * Default value : true. The SPS is faster when it's set to false.
  25193. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25194. */
  25195. computeParticleRotation: boolean;
  25196. /**
  25197. * Tells to `setParticles()` to compute the particle colors or not.
  25198. * Default value : true. The SPS is faster when it's set to false.
  25199. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25200. */
  25201. /**
  25202. * Gets if `setParticles()` computes the particle colors or not.
  25203. * Default value : true. The SPS is faster when it's set to false.
  25204. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25205. */
  25206. computeParticleColor: boolean;
  25207. /**
  25208. * Gets if `setParticles()` computes the particle textures or not.
  25209. * Default value : true. The SPS is faster when it's set to false.
  25210. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25211. */
  25212. computeParticleTexture: boolean;
  25213. /**
  25214. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25215. * Default value : false. The SPS is faster when it's set to false.
  25216. * Note : the particle custom vertex positions aren't stored values.
  25217. */
  25218. /**
  25219. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25220. * Default value : false. The SPS is faster when it's set to false.
  25221. * Note : the particle custom vertex positions aren't stored values.
  25222. */
  25223. computeParticleVertex: boolean;
  25224. /**
  25225. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25226. */
  25227. /**
  25228. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25229. */
  25230. computeBoundingBox: boolean;
  25231. /**
  25232. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25233. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25234. * Default : `true`
  25235. */
  25236. /**
  25237. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25238. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25239. * Default : `true`
  25240. */
  25241. depthSortParticles: boolean;
  25242. /**
  25243. * This function does nothing. It may be overwritten to set all the particle first values.
  25244. * The SPS doesn't call this function, you may have to call it by your own.
  25245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25246. */
  25247. initParticles(): void;
  25248. /**
  25249. * This function does nothing. It may be overwritten to recycle a particle.
  25250. * The SPS doesn't call this function, you may have to call it by your own.
  25251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25252. * @param particle The particle to recycle
  25253. * @returns the recycled particle
  25254. */
  25255. recycleParticle(particle: SolidParticle): SolidParticle;
  25256. /**
  25257. * Updates a particle : this function should be overwritten by the user.
  25258. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25260. * @example : just set a particle position or velocity and recycle conditions
  25261. * @param particle The particle to update
  25262. * @returns the updated particle
  25263. */
  25264. updateParticle(particle: SolidParticle): SolidParticle;
  25265. /**
  25266. * Updates a vertex of a particle : it can be overwritten by the user.
  25267. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25268. * @param particle the current particle
  25269. * @param vertex the current index of the current particle
  25270. * @param pt the index of the current vertex in the particle shape
  25271. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25272. * @example : just set a vertex particle position
  25273. * @returns the updated vertex
  25274. */
  25275. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25276. /**
  25277. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25278. * This does nothing and may be overwritten by the user.
  25279. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25280. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25281. * @param update the boolean update value actually passed to setParticles()
  25282. */
  25283. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25284. /**
  25285. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25286. * This will be passed three parameters.
  25287. * This does nothing and may be overwritten by the user.
  25288. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25289. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25290. * @param update the boolean update value actually passed to setParticles()
  25291. */
  25292. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25293. }
  25294. }
  25295. declare module BABYLON {
  25296. /**
  25297. * Represents one particle of a solid particle system.
  25298. */
  25299. export class SolidParticle {
  25300. /**
  25301. * particle global index
  25302. */
  25303. idx: number;
  25304. /**
  25305. * The color of the particle
  25306. */
  25307. color: Nullable<Color4>;
  25308. /**
  25309. * The world space position of the particle.
  25310. */
  25311. position: Vector3;
  25312. /**
  25313. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25314. */
  25315. rotation: Vector3;
  25316. /**
  25317. * The world space rotation quaternion of the particle.
  25318. */
  25319. rotationQuaternion: Nullable<Quaternion>;
  25320. /**
  25321. * The scaling of the particle.
  25322. */
  25323. scaling: Vector3;
  25324. /**
  25325. * The uvs of the particle.
  25326. */
  25327. uvs: Vector4;
  25328. /**
  25329. * The current speed of the particle.
  25330. */
  25331. velocity: Vector3;
  25332. /**
  25333. * The pivot point in the particle local space.
  25334. */
  25335. pivot: Vector3;
  25336. /**
  25337. * Must the particle be translated from its pivot point in its local space ?
  25338. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25339. * Default : false
  25340. */
  25341. translateFromPivot: boolean;
  25342. /**
  25343. * Is the particle active or not ?
  25344. */
  25345. alive: boolean;
  25346. /**
  25347. * Is the particle visible or not ?
  25348. */
  25349. isVisible: boolean;
  25350. /**
  25351. * Index of this particle in the global "positions" array (Internal use)
  25352. * @hidden
  25353. */
  25354. _pos: number;
  25355. /**
  25356. * @hidden Index of this particle in the global "indices" array (Internal use)
  25357. */
  25358. _ind: number;
  25359. /**
  25360. * @hidden ModelShape of this particle (Internal use)
  25361. */
  25362. _model: ModelShape;
  25363. /**
  25364. * ModelShape id of this particle
  25365. */
  25366. shapeId: number;
  25367. /**
  25368. * Index of the particle in its shape id
  25369. */
  25370. idxInShape: number;
  25371. /**
  25372. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25373. */
  25374. _modelBoundingInfo: BoundingInfo;
  25375. /**
  25376. * @hidden Particle BoundingInfo object (Internal use)
  25377. */
  25378. _boundingInfo: BoundingInfo;
  25379. /**
  25380. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25381. */
  25382. _sps: SolidParticleSystem;
  25383. /**
  25384. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25385. */
  25386. _stillInvisible: boolean;
  25387. /**
  25388. * @hidden Last computed particle rotation matrix
  25389. */
  25390. _rotationMatrix: number[];
  25391. /**
  25392. * Parent particle Id, if any.
  25393. * Default null.
  25394. */
  25395. parentId: Nullable<number>;
  25396. /**
  25397. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25398. * The possible values are :
  25399. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25400. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25401. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25402. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25403. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25404. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25405. * */
  25406. cullingStrategy: number;
  25407. /**
  25408. * @hidden Internal global position in the SPS.
  25409. */
  25410. _globalPosition: Vector3;
  25411. /**
  25412. * Creates a Solid Particle object.
  25413. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25414. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25415. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25416. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25417. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25418. * @param shapeId (integer) is the model shape identifier in the SPS.
  25419. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25420. * @param sps defines the sps it is associated to
  25421. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25422. */
  25423. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25424. /**
  25425. * Legacy support, changed scale to scaling
  25426. */
  25427. /**
  25428. * Legacy support, changed scale to scaling
  25429. */
  25430. scale: Vector3;
  25431. /**
  25432. * Legacy support, changed quaternion to rotationQuaternion
  25433. */
  25434. /**
  25435. * Legacy support, changed quaternion to rotationQuaternion
  25436. */
  25437. quaternion: Nullable<Quaternion>;
  25438. /**
  25439. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25440. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25441. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25442. * @returns true if it intersects
  25443. */
  25444. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25445. /**
  25446. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25447. * A particle is in the frustum if its bounding box intersects the frustum
  25448. * @param frustumPlanes defines the frustum to test
  25449. * @returns true if the particle is in the frustum planes
  25450. */
  25451. isInFrustum(frustumPlanes: Plane[]): boolean;
  25452. /**
  25453. * get the rotation matrix of the particle
  25454. * @hidden
  25455. */
  25456. getRotationMatrix(m: Matrix): void;
  25457. }
  25458. /**
  25459. * Represents the shape of the model used by one particle of a solid particle system.
  25460. * SPS internal tool, don't use it manually.
  25461. */
  25462. export class ModelShape {
  25463. /**
  25464. * The shape id
  25465. * @hidden
  25466. */
  25467. shapeID: number;
  25468. /**
  25469. * flat array of model positions (internal use)
  25470. * @hidden
  25471. */
  25472. _shape: Vector3[];
  25473. /**
  25474. * flat array of model UVs (internal use)
  25475. * @hidden
  25476. */
  25477. _shapeUV: number[];
  25478. /**
  25479. * length of the shape in the model indices array (internal use)
  25480. * @hidden
  25481. */
  25482. _indicesLength: number;
  25483. /**
  25484. * Custom position function (internal use)
  25485. * @hidden
  25486. */
  25487. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25488. /**
  25489. * Custom vertex function (internal use)
  25490. * @hidden
  25491. */
  25492. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25493. /**
  25494. * 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.
  25495. * SPS internal tool, don't use it manually.
  25496. * @hidden
  25497. */
  25498. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25499. }
  25500. /**
  25501. * Represents a Depth Sorted Particle in the solid particle system.
  25502. */
  25503. export class DepthSortedParticle {
  25504. /**
  25505. * Index of the particle in the "indices" array
  25506. */
  25507. ind: number;
  25508. /**
  25509. * Length of the particle shape in the "indices" array
  25510. */
  25511. indicesLength: number;
  25512. /**
  25513. * Squared distance from the particle to the camera
  25514. */
  25515. sqDistance: number;
  25516. }
  25517. }
  25518. declare module BABYLON {
  25519. /**
  25520. * @hidden
  25521. */
  25522. export class _MeshCollisionData {
  25523. _checkCollisions: boolean;
  25524. _collisionMask: number;
  25525. _collisionGroup: number;
  25526. _collider: Nullable<Collider>;
  25527. _oldPositionForCollisions: Vector3;
  25528. _diffPositionForCollisions: Vector3;
  25529. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25530. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25531. }
  25532. }
  25533. declare module BABYLON {
  25534. /** @hidden */
  25535. class _FacetDataStorage {
  25536. facetPositions: Vector3[];
  25537. facetNormals: Vector3[];
  25538. facetPartitioning: number[][];
  25539. facetNb: number;
  25540. partitioningSubdivisions: number;
  25541. partitioningBBoxRatio: number;
  25542. facetDataEnabled: boolean;
  25543. facetParameters: any;
  25544. bbSize: Vector3;
  25545. subDiv: {
  25546. max: number;
  25547. X: number;
  25548. Y: number;
  25549. Z: number;
  25550. };
  25551. facetDepthSort: boolean;
  25552. facetDepthSortEnabled: boolean;
  25553. depthSortedIndices: IndicesArray;
  25554. depthSortedFacets: {
  25555. ind: number;
  25556. sqDistance: number;
  25557. }[];
  25558. facetDepthSortFunction: (f1: {
  25559. ind: number;
  25560. sqDistance: number;
  25561. }, f2: {
  25562. ind: number;
  25563. sqDistance: number;
  25564. }) => number;
  25565. facetDepthSortFrom: Vector3;
  25566. facetDepthSortOrigin: Vector3;
  25567. invertedMatrix: Matrix;
  25568. }
  25569. /**
  25570. * @hidden
  25571. **/
  25572. class _InternalAbstractMeshDataInfo {
  25573. _hasVertexAlpha: boolean;
  25574. _useVertexColors: boolean;
  25575. _numBoneInfluencers: number;
  25576. _applyFog: boolean;
  25577. _receiveShadows: boolean;
  25578. _facetData: _FacetDataStorage;
  25579. _visibility: number;
  25580. _skeleton: Nullable<Skeleton>;
  25581. _layerMask: number;
  25582. _computeBonesUsingShaders: boolean;
  25583. _isActive: boolean;
  25584. _onlyForInstances: boolean;
  25585. _isActiveIntermediate: boolean;
  25586. _onlyForInstancesIntermediate: boolean;
  25587. }
  25588. /**
  25589. * Class used to store all common mesh properties
  25590. */
  25591. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25592. /** No occlusion */
  25593. static OCCLUSION_TYPE_NONE: number;
  25594. /** Occlusion set to optimisitic */
  25595. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25596. /** Occlusion set to strict */
  25597. static OCCLUSION_TYPE_STRICT: number;
  25598. /** Use an accurante occlusion algorithm */
  25599. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25600. /** Use a conservative occlusion algorithm */
  25601. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25602. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25603. * Test order :
  25604. * Is the bounding sphere outside the frustum ?
  25605. * If not, are the bounding box vertices outside the frustum ?
  25606. * It not, then the cullable object is in the frustum.
  25607. */
  25608. static readonly CULLINGSTRATEGY_STANDARD: number;
  25609. /** Culling strategy : Bounding Sphere Only.
  25610. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25611. * It's also less accurate than the standard because some not visible objects can still be selected.
  25612. * Test : is the bounding sphere outside the frustum ?
  25613. * If not, then the cullable object is in the frustum.
  25614. */
  25615. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25616. /** Culling strategy : Optimistic Inclusion.
  25617. * This in an inclusion test first, then the standard exclusion test.
  25618. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25619. * 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.
  25620. * Anyway, it's as accurate as the standard strategy.
  25621. * Test :
  25622. * Is the cullable object bounding sphere center in the frustum ?
  25623. * If not, apply the default culling strategy.
  25624. */
  25625. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25626. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25627. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25628. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25629. * 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.
  25630. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25631. * Test :
  25632. * Is the cullable object bounding sphere center in the frustum ?
  25633. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25634. */
  25635. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25636. /**
  25637. * No billboard
  25638. */
  25639. static readonly BILLBOARDMODE_NONE: number;
  25640. /** Billboard on X axis */
  25641. static readonly BILLBOARDMODE_X: number;
  25642. /** Billboard on Y axis */
  25643. static readonly BILLBOARDMODE_Y: number;
  25644. /** Billboard on Z axis */
  25645. static readonly BILLBOARDMODE_Z: number;
  25646. /** Billboard on all axes */
  25647. static readonly BILLBOARDMODE_ALL: number;
  25648. /** Billboard on using position instead of orientation */
  25649. static readonly BILLBOARDMODE_USE_POSITION: number;
  25650. /** @hidden */
  25651. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25652. /**
  25653. * The culling strategy to use to check whether the mesh must be rendered or not.
  25654. * This value can be changed at any time and will be used on the next render mesh selection.
  25655. * The possible values are :
  25656. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25657. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25658. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25659. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25660. * Please read each static variable documentation to get details about the culling process.
  25661. * */
  25662. cullingStrategy: number;
  25663. /**
  25664. * Gets the number of facets in the mesh
  25665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25666. */
  25667. readonly facetNb: number;
  25668. /**
  25669. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25671. */
  25672. partitioningSubdivisions: number;
  25673. /**
  25674. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25675. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25677. */
  25678. partitioningBBoxRatio: number;
  25679. /**
  25680. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25681. * Works only for updatable meshes.
  25682. * Doesn't work with multi-materials
  25683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25684. */
  25685. mustDepthSortFacets: boolean;
  25686. /**
  25687. * The location (Vector3) where the facet depth sort must be computed from.
  25688. * By default, the active camera position.
  25689. * Used only when facet depth sort is enabled
  25690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25691. */
  25692. facetDepthSortFrom: Vector3;
  25693. /**
  25694. * gets a boolean indicating if facetData is enabled
  25695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25696. */
  25697. readonly isFacetDataEnabled: boolean;
  25698. /** @hidden */
  25699. _updateNonUniformScalingState(value: boolean): boolean;
  25700. /**
  25701. * An event triggered when this mesh collides with another one
  25702. */
  25703. onCollideObservable: Observable<AbstractMesh>;
  25704. /** Set a function to call when this mesh collides with another one */
  25705. onCollide: () => void;
  25706. /**
  25707. * An event triggered when the collision's position changes
  25708. */
  25709. onCollisionPositionChangeObservable: Observable<Vector3>;
  25710. /** Set a function to call when the collision's position changes */
  25711. onCollisionPositionChange: () => void;
  25712. /**
  25713. * An event triggered when material is changed
  25714. */
  25715. onMaterialChangedObservable: Observable<AbstractMesh>;
  25716. /**
  25717. * Gets or sets the orientation for POV movement & rotation
  25718. */
  25719. definedFacingForward: boolean;
  25720. /** @hidden */
  25721. _occlusionQuery: Nullable<WebGLQuery>;
  25722. /** @hidden */
  25723. _renderingGroup: Nullable<RenderingGroup>;
  25724. /**
  25725. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25726. */
  25727. /**
  25728. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25729. */
  25730. visibility: number;
  25731. /** Gets or sets the alpha index used to sort transparent meshes
  25732. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25733. */
  25734. alphaIndex: number;
  25735. /**
  25736. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25737. */
  25738. isVisible: boolean;
  25739. /**
  25740. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25741. */
  25742. isPickable: boolean;
  25743. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25744. showSubMeshesBoundingBox: boolean;
  25745. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25746. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25747. */
  25748. isBlocker: boolean;
  25749. /**
  25750. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25751. */
  25752. enablePointerMoveEvents: boolean;
  25753. /**
  25754. * Specifies the rendering group id for this mesh (0 by default)
  25755. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25756. */
  25757. renderingGroupId: number;
  25758. private _material;
  25759. /** Gets or sets current material */
  25760. material: Nullable<Material>;
  25761. /**
  25762. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25763. * @see http://doc.babylonjs.com/babylon101/shadows
  25764. */
  25765. receiveShadows: boolean;
  25766. /** Defines color to use when rendering outline */
  25767. outlineColor: Color3;
  25768. /** Define width to use when rendering outline */
  25769. outlineWidth: number;
  25770. /** Defines color to use when rendering overlay */
  25771. overlayColor: Color3;
  25772. /** Defines alpha to use when rendering overlay */
  25773. overlayAlpha: number;
  25774. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25775. hasVertexAlpha: boolean;
  25776. /** 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) */
  25777. useVertexColors: boolean;
  25778. /**
  25779. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25780. */
  25781. computeBonesUsingShaders: boolean;
  25782. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25783. numBoneInfluencers: number;
  25784. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25785. applyFog: boolean;
  25786. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25787. useOctreeForRenderingSelection: boolean;
  25788. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25789. useOctreeForPicking: boolean;
  25790. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25791. useOctreeForCollisions: boolean;
  25792. /**
  25793. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25794. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25795. */
  25796. layerMask: number;
  25797. /**
  25798. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25799. */
  25800. alwaysSelectAsActiveMesh: boolean;
  25801. /**
  25802. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25803. */
  25804. doNotSyncBoundingInfo: boolean;
  25805. /**
  25806. * Gets or sets the current action manager
  25807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25808. */
  25809. actionManager: Nullable<AbstractActionManager>;
  25810. private _meshCollisionData;
  25811. /**
  25812. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25814. */
  25815. ellipsoid: Vector3;
  25816. /**
  25817. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25819. */
  25820. ellipsoidOffset: Vector3;
  25821. /**
  25822. * Gets or sets a collision mask used to mask collisions (default is -1).
  25823. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25824. */
  25825. collisionMask: number;
  25826. /**
  25827. * Gets or sets the current collision group mask (-1 by default).
  25828. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25829. */
  25830. collisionGroup: number;
  25831. /**
  25832. * Defines edge width used when edgesRenderer is enabled
  25833. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25834. */
  25835. edgesWidth: number;
  25836. /**
  25837. * Defines edge color used when edgesRenderer is enabled
  25838. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25839. */
  25840. edgesColor: Color4;
  25841. /** @hidden */
  25842. _edgesRenderer: Nullable<IEdgesRenderer>;
  25843. /** @hidden */
  25844. _masterMesh: Nullable<AbstractMesh>;
  25845. /** @hidden */
  25846. _boundingInfo: Nullable<BoundingInfo>;
  25847. /** @hidden */
  25848. _renderId: number;
  25849. /**
  25850. * Gets or sets the list of subMeshes
  25851. * @see http://doc.babylonjs.com/how_to/multi_materials
  25852. */
  25853. subMeshes: SubMesh[];
  25854. /** @hidden */
  25855. _intersectionsInProgress: AbstractMesh[];
  25856. /** @hidden */
  25857. _unIndexed: boolean;
  25858. /** @hidden */
  25859. _lightSources: Light[];
  25860. /** Gets the list of lights affecting that mesh */
  25861. readonly lightSources: Light[];
  25862. /** @hidden */
  25863. readonly _positions: Nullable<Vector3[]>;
  25864. /** @hidden */
  25865. _waitingData: {
  25866. lods: Nullable<any>;
  25867. actions: Nullable<any>;
  25868. freezeWorldMatrix: Nullable<boolean>;
  25869. };
  25870. /** @hidden */
  25871. _bonesTransformMatrices: Nullable<Float32Array>;
  25872. /** @hidden */
  25873. _transformMatrixTexture: Nullable<RawTexture>;
  25874. /**
  25875. * Gets or sets a skeleton to apply skining transformations
  25876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25877. */
  25878. skeleton: Nullable<Skeleton>;
  25879. /**
  25880. * An event triggered when the mesh is rebuilt.
  25881. */
  25882. onRebuildObservable: Observable<AbstractMesh>;
  25883. /**
  25884. * Creates a new AbstractMesh
  25885. * @param name defines the name of the mesh
  25886. * @param scene defines the hosting scene
  25887. */
  25888. constructor(name: string, scene?: Nullable<Scene>);
  25889. /**
  25890. * Returns the string "AbstractMesh"
  25891. * @returns "AbstractMesh"
  25892. */
  25893. getClassName(): string;
  25894. /**
  25895. * Gets a string representation of the current mesh
  25896. * @param fullDetails defines a boolean indicating if full details must be included
  25897. * @returns a string representation of the current mesh
  25898. */
  25899. toString(fullDetails?: boolean): string;
  25900. /**
  25901. * @hidden
  25902. */
  25903. protected _getEffectiveParent(): Nullable<Node>;
  25904. /** @hidden */
  25905. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25906. /** @hidden */
  25907. _rebuild(): void;
  25908. /** @hidden */
  25909. _resyncLightSources(): void;
  25910. /** @hidden */
  25911. _resyncLighSource(light: Light): void;
  25912. /** @hidden */
  25913. _unBindEffect(): void;
  25914. /** @hidden */
  25915. _removeLightSource(light: Light, dispose: boolean): void;
  25916. private _markSubMeshesAsDirty;
  25917. /** @hidden */
  25918. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25919. /** @hidden */
  25920. _markSubMeshesAsAttributesDirty(): void;
  25921. /** @hidden */
  25922. _markSubMeshesAsMiscDirty(): void;
  25923. /**
  25924. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25925. */
  25926. scaling: Vector3;
  25927. /**
  25928. * Returns true if the mesh is blocked. Implemented by child classes
  25929. */
  25930. readonly isBlocked: boolean;
  25931. /**
  25932. * Returns the mesh itself by default. Implemented by child classes
  25933. * @param camera defines the camera to use to pick the right LOD level
  25934. * @returns the currentAbstractMesh
  25935. */
  25936. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25937. /**
  25938. * Returns 0 by default. Implemented by child classes
  25939. * @returns an integer
  25940. */
  25941. getTotalVertices(): number;
  25942. /**
  25943. * Returns a positive integer : the total number of indices in this mesh geometry.
  25944. * @returns the numner of indices or zero if the mesh has no geometry.
  25945. */
  25946. getTotalIndices(): number;
  25947. /**
  25948. * Returns null by default. Implemented by child classes
  25949. * @returns null
  25950. */
  25951. getIndices(): Nullable<IndicesArray>;
  25952. /**
  25953. * Returns the array of the requested vertex data kind. Implemented by child classes
  25954. * @param kind defines the vertex data kind to use
  25955. * @returns null
  25956. */
  25957. getVerticesData(kind: string): Nullable<FloatArray>;
  25958. /**
  25959. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25960. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25961. * Note that a new underlying VertexBuffer object is created each call.
  25962. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25963. * @param kind defines vertex data kind:
  25964. * * VertexBuffer.PositionKind
  25965. * * VertexBuffer.UVKind
  25966. * * VertexBuffer.UV2Kind
  25967. * * VertexBuffer.UV3Kind
  25968. * * VertexBuffer.UV4Kind
  25969. * * VertexBuffer.UV5Kind
  25970. * * VertexBuffer.UV6Kind
  25971. * * VertexBuffer.ColorKind
  25972. * * VertexBuffer.MatricesIndicesKind
  25973. * * VertexBuffer.MatricesIndicesExtraKind
  25974. * * VertexBuffer.MatricesWeightsKind
  25975. * * VertexBuffer.MatricesWeightsExtraKind
  25976. * @param data defines the data source
  25977. * @param updatable defines if the data must be flagged as updatable (or static)
  25978. * @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
  25979. * @returns the current mesh
  25980. */
  25981. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25982. /**
  25983. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25984. * If the mesh has no geometry, it is simply returned as it is.
  25985. * @param kind defines vertex data kind:
  25986. * * VertexBuffer.PositionKind
  25987. * * VertexBuffer.UVKind
  25988. * * VertexBuffer.UV2Kind
  25989. * * VertexBuffer.UV3Kind
  25990. * * VertexBuffer.UV4Kind
  25991. * * VertexBuffer.UV5Kind
  25992. * * VertexBuffer.UV6Kind
  25993. * * VertexBuffer.ColorKind
  25994. * * VertexBuffer.MatricesIndicesKind
  25995. * * VertexBuffer.MatricesIndicesExtraKind
  25996. * * VertexBuffer.MatricesWeightsKind
  25997. * * VertexBuffer.MatricesWeightsExtraKind
  25998. * @param data defines the data source
  25999. * @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
  26000. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26001. * @returns the current mesh
  26002. */
  26003. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26004. /**
  26005. * Sets the mesh indices,
  26006. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26007. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26008. * @param totalVertices Defines the total number of vertices
  26009. * @returns the current mesh
  26010. */
  26011. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26012. /**
  26013. * Gets a boolean indicating if specific vertex data is present
  26014. * @param kind defines the vertex data kind to use
  26015. * @returns true is data kind is present
  26016. */
  26017. isVerticesDataPresent(kind: string): boolean;
  26018. /**
  26019. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26020. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26021. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26022. * @returns a BoundingInfo
  26023. */
  26024. getBoundingInfo(): BoundingInfo;
  26025. /**
  26026. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26027. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26028. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26029. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26030. * @returns the current mesh
  26031. */
  26032. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26033. /**
  26034. * Overwrite the current bounding info
  26035. * @param boundingInfo defines the new bounding info
  26036. * @returns the current mesh
  26037. */
  26038. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26039. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26040. readonly useBones: boolean;
  26041. /** @hidden */
  26042. _preActivate(): void;
  26043. /** @hidden */
  26044. _preActivateForIntermediateRendering(renderId: number): void;
  26045. /** @hidden */
  26046. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26047. /** @hidden */
  26048. _postActivate(): void;
  26049. /** @hidden */
  26050. _freeze(): void;
  26051. /** @hidden */
  26052. _unFreeze(): void;
  26053. /**
  26054. * Gets the current world matrix
  26055. * @returns a Matrix
  26056. */
  26057. getWorldMatrix(): Matrix;
  26058. /** @hidden */
  26059. _getWorldMatrixDeterminant(): number;
  26060. /**
  26061. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26062. */
  26063. readonly isAnInstance: boolean;
  26064. /**
  26065. * Gets a boolean indicating if this mesh has instances
  26066. */
  26067. readonly hasInstances: boolean;
  26068. /**
  26069. * Perform relative position change from the point of view of behind the front of the mesh.
  26070. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26071. * Supports definition of mesh facing forward or backward
  26072. * @param amountRight defines the distance on the right axis
  26073. * @param amountUp defines the distance on the up axis
  26074. * @param amountForward defines the distance on the forward axis
  26075. * @returns the current mesh
  26076. */
  26077. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26078. /**
  26079. * Calculate relative position change from the point of view of behind the front of the mesh.
  26080. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26081. * Supports definition of mesh facing forward or backward
  26082. * @param amountRight defines the distance on the right axis
  26083. * @param amountUp defines the distance on the up axis
  26084. * @param amountForward defines the distance on the forward axis
  26085. * @returns the new displacement vector
  26086. */
  26087. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26088. /**
  26089. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26090. * Supports definition of mesh facing forward or backward
  26091. * @param flipBack defines the flip
  26092. * @param twirlClockwise defines the twirl
  26093. * @param tiltRight defines the tilt
  26094. * @returns the current mesh
  26095. */
  26096. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26097. /**
  26098. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26099. * Supports definition of mesh facing forward or backward.
  26100. * @param flipBack defines the flip
  26101. * @param twirlClockwise defines the twirl
  26102. * @param tiltRight defines the tilt
  26103. * @returns the new rotation vector
  26104. */
  26105. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26106. /**
  26107. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26108. * This means the mesh underlying bounding box and sphere are recomputed.
  26109. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26110. * @returns the current mesh
  26111. */
  26112. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26113. /** @hidden */
  26114. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26115. /** @hidden */
  26116. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26117. /** @hidden */
  26118. _updateBoundingInfo(): AbstractMesh;
  26119. /** @hidden */
  26120. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26121. /** @hidden */
  26122. protected _afterComputeWorldMatrix(): void;
  26123. /** @hidden */
  26124. readonly _effectiveMesh: AbstractMesh;
  26125. /**
  26126. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26127. * A mesh is in the frustum if its bounding box intersects the frustum
  26128. * @param frustumPlanes defines the frustum to test
  26129. * @returns true if the mesh is in the frustum planes
  26130. */
  26131. isInFrustum(frustumPlanes: Plane[]): boolean;
  26132. /**
  26133. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26134. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26135. * @param frustumPlanes defines the frustum to test
  26136. * @returns true if the mesh is completely in the frustum planes
  26137. */
  26138. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26139. /**
  26140. * True if the mesh intersects another mesh or a SolidParticle object
  26141. * @param mesh defines a target mesh or SolidParticle to test
  26142. * @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)
  26143. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26144. * @returns true if there is an intersection
  26145. */
  26146. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26147. /**
  26148. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26149. * @param point defines the point to test
  26150. * @returns true if there is an intersection
  26151. */
  26152. intersectsPoint(point: Vector3): boolean;
  26153. /**
  26154. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26156. */
  26157. checkCollisions: boolean;
  26158. /**
  26159. * Gets Collider object used to compute collisions (not physics)
  26160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26161. */
  26162. readonly collider: Nullable<Collider>;
  26163. /**
  26164. * Move the mesh using collision engine
  26165. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26166. * @param displacement defines the requested displacement vector
  26167. * @returns the current mesh
  26168. */
  26169. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26170. private _onCollisionPositionChange;
  26171. /** @hidden */
  26172. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26173. /** @hidden */
  26174. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26175. /** @hidden */
  26176. _checkCollision(collider: Collider): AbstractMesh;
  26177. /** @hidden */
  26178. _generatePointsArray(): boolean;
  26179. /**
  26180. * Checks if the passed Ray intersects with the mesh
  26181. * @param ray defines the ray to use
  26182. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26184. * @returns the picking info
  26185. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26186. */
  26187. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26188. /**
  26189. * Clones the current mesh
  26190. * @param name defines the mesh name
  26191. * @param newParent defines the new mesh parent
  26192. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26193. * @returns the new mesh
  26194. */
  26195. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26196. /**
  26197. * Disposes all the submeshes of the current meshnp
  26198. * @returns the current mesh
  26199. */
  26200. releaseSubMeshes(): AbstractMesh;
  26201. /**
  26202. * Releases resources associated with this abstract mesh.
  26203. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26204. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26205. */
  26206. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26207. /**
  26208. * Adds the passed mesh as a child to the current mesh
  26209. * @param mesh defines the child mesh
  26210. * @returns the current mesh
  26211. */
  26212. addChild(mesh: AbstractMesh): AbstractMesh;
  26213. /**
  26214. * Removes the passed mesh from the current mesh children list
  26215. * @param mesh defines the child mesh
  26216. * @returns the current mesh
  26217. */
  26218. removeChild(mesh: AbstractMesh): AbstractMesh;
  26219. /** @hidden */
  26220. private _initFacetData;
  26221. /**
  26222. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26223. * This method can be called within the render loop.
  26224. * 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
  26225. * @returns the current mesh
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26227. */
  26228. updateFacetData(): AbstractMesh;
  26229. /**
  26230. * Returns the facetLocalNormals array.
  26231. * The normals are expressed in the mesh local spac
  26232. * @returns an array of Vector3
  26233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26234. */
  26235. getFacetLocalNormals(): Vector3[];
  26236. /**
  26237. * Returns the facetLocalPositions array.
  26238. * The facet positions are expressed in the mesh local space
  26239. * @returns an array of Vector3
  26240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26241. */
  26242. getFacetLocalPositions(): Vector3[];
  26243. /**
  26244. * Returns the facetLocalPartioning array
  26245. * @returns an array of array of numbers
  26246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26247. */
  26248. getFacetLocalPartitioning(): number[][];
  26249. /**
  26250. * Returns the i-th facet position in the world system.
  26251. * This method allocates a new Vector3 per call
  26252. * @param i defines the facet index
  26253. * @returns a new Vector3
  26254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26255. */
  26256. getFacetPosition(i: number): Vector3;
  26257. /**
  26258. * Sets the reference Vector3 with the i-th facet position in the world system
  26259. * @param i defines the facet index
  26260. * @param ref defines the target vector
  26261. * @returns the current mesh
  26262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26263. */
  26264. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26265. /**
  26266. * Returns the i-th facet normal in the world system.
  26267. * This method allocates a new Vector3 per call
  26268. * @param i defines the facet index
  26269. * @returns a new Vector3
  26270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26271. */
  26272. getFacetNormal(i: number): Vector3;
  26273. /**
  26274. * Sets the reference Vector3 with the i-th facet normal in the world system
  26275. * @param i defines the facet index
  26276. * @param ref defines the target vector
  26277. * @returns the current mesh
  26278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26279. */
  26280. getFacetNormalToRef(i: number, ref: Vector3): this;
  26281. /**
  26282. * 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)
  26283. * @param x defines x coordinate
  26284. * @param y defines y coordinate
  26285. * @param z defines z coordinate
  26286. * @returns the array of facet indexes
  26287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26288. */
  26289. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26290. /**
  26291. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26292. * @param projected sets as the (x,y,z) world projection on the facet
  26293. * @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
  26294. * @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
  26295. * @param x defines x coordinate
  26296. * @param y defines y coordinate
  26297. * @param z defines z coordinate
  26298. * @returns the face index if found (or null instead)
  26299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26300. */
  26301. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26302. /**
  26303. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26304. * @param projected sets as the (x,y,z) local projection on the facet
  26305. * @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
  26306. * @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
  26307. * @param x defines x coordinate
  26308. * @param y defines y coordinate
  26309. * @param z defines z coordinate
  26310. * @returns the face index if found (or null instead)
  26311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26312. */
  26313. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26314. /**
  26315. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26316. * @returns the parameters
  26317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26318. */
  26319. getFacetDataParameters(): any;
  26320. /**
  26321. * Disables the feature FacetData and frees the related memory
  26322. * @returns the current mesh
  26323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26324. */
  26325. disableFacetData(): AbstractMesh;
  26326. /**
  26327. * Updates the AbstractMesh indices array
  26328. * @param indices defines the data source
  26329. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26330. * @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)
  26331. * @returns the current mesh
  26332. */
  26333. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26334. /**
  26335. * Creates new normals data for the mesh
  26336. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26337. * @returns the current mesh
  26338. */
  26339. createNormals(updatable: boolean): AbstractMesh;
  26340. /**
  26341. * Align the mesh with a normal
  26342. * @param normal defines the normal to use
  26343. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26344. * @returns the current mesh
  26345. */
  26346. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26347. /** @hidden */
  26348. _checkOcclusionQuery(): boolean;
  26349. /**
  26350. * Disables the mesh edge rendering mode
  26351. * @returns the currentAbstractMesh
  26352. */
  26353. disableEdgesRendering(): AbstractMesh;
  26354. /**
  26355. * Enables the edge rendering mode on the mesh.
  26356. * This mode makes the mesh edges visible
  26357. * @param epsilon defines the maximal distance between two angles to detect a face
  26358. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26359. * @returns the currentAbstractMesh
  26360. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26361. */
  26362. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26363. }
  26364. }
  26365. declare module BABYLON {
  26366. /**
  26367. * Interface used to define ActionEvent
  26368. */
  26369. export interface IActionEvent {
  26370. /** The mesh or sprite that triggered the action */
  26371. source: any;
  26372. /** The X mouse cursor position at the time of the event */
  26373. pointerX: number;
  26374. /** The Y mouse cursor position at the time of the event */
  26375. pointerY: number;
  26376. /** The mesh that is currently pointed at (can be null) */
  26377. meshUnderPointer: Nullable<AbstractMesh>;
  26378. /** the original (browser) event that triggered the ActionEvent */
  26379. sourceEvent?: any;
  26380. /** additional data for the event */
  26381. additionalData?: any;
  26382. }
  26383. /**
  26384. * ActionEvent is the event being sent when an action is triggered.
  26385. */
  26386. export class ActionEvent implements IActionEvent {
  26387. /** The mesh or sprite that triggered the action */
  26388. source: any;
  26389. /** The X mouse cursor position at the time of the event */
  26390. pointerX: number;
  26391. /** The Y mouse cursor position at the time of the event */
  26392. pointerY: number;
  26393. /** The mesh that is currently pointed at (can be null) */
  26394. meshUnderPointer: Nullable<AbstractMesh>;
  26395. /** the original (browser) event that triggered the ActionEvent */
  26396. sourceEvent?: any;
  26397. /** additional data for the event */
  26398. additionalData?: any;
  26399. /**
  26400. * Creates a new ActionEvent
  26401. * @param source The mesh or sprite that triggered the action
  26402. * @param pointerX The X mouse cursor position at the time of the event
  26403. * @param pointerY The Y mouse cursor position at the time of the event
  26404. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26405. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26406. * @param additionalData additional data for the event
  26407. */
  26408. constructor(
  26409. /** The mesh or sprite that triggered the action */
  26410. source: any,
  26411. /** The X mouse cursor position at the time of the event */
  26412. pointerX: number,
  26413. /** The Y mouse cursor position at the time of the event */
  26414. pointerY: number,
  26415. /** The mesh that is currently pointed at (can be null) */
  26416. meshUnderPointer: Nullable<AbstractMesh>,
  26417. /** the original (browser) event that triggered the ActionEvent */
  26418. sourceEvent?: any,
  26419. /** additional data for the event */
  26420. additionalData?: any);
  26421. /**
  26422. * Helper function to auto-create an ActionEvent from a source mesh.
  26423. * @param source The source mesh that triggered the event
  26424. * @param evt The original (browser) event
  26425. * @param additionalData additional data for the event
  26426. * @returns the new ActionEvent
  26427. */
  26428. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26429. /**
  26430. * Helper function to auto-create an ActionEvent from a source sprite
  26431. * @param source The source sprite that triggered the event
  26432. * @param scene Scene associated with the sprite
  26433. * @param evt The original (browser) event
  26434. * @param additionalData additional data for the event
  26435. * @returns the new ActionEvent
  26436. */
  26437. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26438. /**
  26439. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26440. * @param scene the scene where the event occurred
  26441. * @param evt The original (browser) event
  26442. * @returns the new ActionEvent
  26443. */
  26444. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26445. /**
  26446. * Helper function to auto-create an ActionEvent from a primitive
  26447. * @param prim defines the target primitive
  26448. * @param pointerPos defines the pointer position
  26449. * @param evt The original (browser) event
  26450. * @param additionalData additional data for the event
  26451. * @returns the new ActionEvent
  26452. */
  26453. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26454. }
  26455. }
  26456. declare module BABYLON {
  26457. /**
  26458. * Abstract class used to decouple action Manager from scene and meshes.
  26459. * Do not instantiate.
  26460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26461. */
  26462. export abstract class AbstractActionManager implements IDisposable {
  26463. /** Gets the list of active triggers */
  26464. static Triggers: {
  26465. [key: string]: number;
  26466. };
  26467. /** Gets the cursor to use when hovering items */
  26468. hoverCursor: string;
  26469. /** Gets the list of actions */
  26470. actions: IAction[];
  26471. /**
  26472. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26473. */
  26474. isRecursive: boolean;
  26475. /**
  26476. * Releases all associated resources
  26477. */
  26478. abstract dispose(): void;
  26479. /**
  26480. * Does this action manager has pointer triggers
  26481. */
  26482. abstract readonly hasPointerTriggers: boolean;
  26483. /**
  26484. * Does this action manager has pick triggers
  26485. */
  26486. abstract readonly hasPickTriggers: boolean;
  26487. /**
  26488. * Process a specific trigger
  26489. * @param trigger defines the trigger to process
  26490. * @param evt defines the event details to be processed
  26491. */
  26492. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26493. /**
  26494. * Does this action manager handles actions of any of the given triggers
  26495. * @param triggers defines the triggers to be tested
  26496. * @return a boolean indicating whether one (or more) of the triggers is handled
  26497. */
  26498. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26499. /**
  26500. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26501. * speed.
  26502. * @param triggerA defines the trigger to be tested
  26503. * @param triggerB defines the trigger to be tested
  26504. * @return a boolean indicating whether one (or more) of the triggers is handled
  26505. */
  26506. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26507. /**
  26508. * Does this action manager handles actions of a given trigger
  26509. * @param trigger defines the trigger to be tested
  26510. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26511. * @return whether the trigger is handled
  26512. */
  26513. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26514. /**
  26515. * Serialize this manager to a JSON object
  26516. * @param name defines the property name to store this manager
  26517. * @returns a JSON representation of this manager
  26518. */
  26519. abstract serialize(name: string): any;
  26520. /**
  26521. * Registers an action to this action manager
  26522. * @param action defines the action to be registered
  26523. * @return the action amended (prepared) after registration
  26524. */
  26525. abstract registerAction(action: IAction): Nullable<IAction>;
  26526. /**
  26527. * Unregisters an action to this action manager
  26528. * @param action defines the action to be unregistered
  26529. * @return a boolean indicating whether the action has been unregistered
  26530. */
  26531. abstract unregisterAction(action: IAction): Boolean;
  26532. /**
  26533. * Does exist one action manager with at least one trigger
  26534. **/
  26535. static readonly HasTriggers: boolean;
  26536. /**
  26537. * Does exist one action manager with at least one pick trigger
  26538. **/
  26539. static readonly HasPickTriggers: boolean;
  26540. /**
  26541. * Does exist one action manager that handles actions of a given trigger
  26542. * @param trigger defines the trigger to be tested
  26543. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26544. **/
  26545. static HasSpecificTrigger(trigger: number): boolean;
  26546. }
  26547. }
  26548. declare module BABYLON {
  26549. /**
  26550. * Defines how a node can be built from a string name.
  26551. */
  26552. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26553. /**
  26554. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26555. */
  26556. export class Node implements IBehaviorAware<Node> {
  26557. /** @hidden */
  26558. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26559. private static _NodeConstructors;
  26560. /**
  26561. * Add a new node constructor
  26562. * @param type defines the type name of the node to construct
  26563. * @param constructorFunc defines the constructor function
  26564. */
  26565. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26566. /**
  26567. * Returns a node constructor based on type name
  26568. * @param type defines the type name
  26569. * @param name defines the new node name
  26570. * @param scene defines the hosting scene
  26571. * @param options defines optional options to transmit to constructors
  26572. * @returns the new constructor or null
  26573. */
  26574. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26575. /**
  26576. * Gets or sets the name of the node
  26577. */
  26578. name: string;
  26579. /**
  26580. * Gets or sets the id of the node
  26581. */
  26582. id: string;
  26583. /**
  26584. * Gets or sets the unique id of the node
  26585. */
  26586. uniqueId: number;
  26587. /**
  26588. * Gets or sets a string used to store user defined state for the node
  26589. */
  26590. state: string;
  26591. /**
  26592. * Gets or sets an object used to store user defined information for the node
  26593. */
  26594. metadata: any;
  26595. /**
  26596. * For internal use only. Please do not use.
  26597. */
  26598. reservedDataStore: any;
  26599. /**
  26600. * List of inspectable custom properties (used by the Inspector)
  26601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26602. */
  26603. inspectableCustomProperties: IInspectable[];
  26604. /**
  26605. * Gets or sets a boolean used to define if the node must be serialized
  26606. */
  26607. doNotSerialize: boolean;
  26608. /** @hidden */
  26609. _isDisposed: boolean;
  26610. /**
  26611. * Gets a list of Animations associated with the node
  26612. */
  26613. animations: Animation[];
  26614. protected _ranges: {
  26615. [name: string]: Nullable<AnimationRange>;
  26616. };
  26617. /**
  26618. * Callback raised when the node is ready to be used
  26619. */
  26620. onReady: Nullable<(node: Node) => void>;
  26621. private _isEnabled;
  26622. private _isParentEnabled;
  26623. private _isReady;
  26624. /** @hidden */
  26625. _currentRenderId: number;
  26626. private _parentUpdateId;
  26627. /** @hidden */
  26628. _childUpdateId: number;
  26629. /** @hidden */
  26630. _waitingParentId: Nullable<string>;
  26631. /** @hidden */
  26632. _scene: Scene;
  26633. /** @hidden */
  26634. _cache: any;
  26635. private _parentNode;
  26636. private _children;
  26637. /** @hidden */
  26638. _worldMatrix: Matrix;
  26639. /** @hidden */
  26640. _worldMatrixDeterminant: number;
  26641. /** @hidden */
  26642. _worldMatrixDeterminantIsDirty: boolean;
  26643. /** @hidden */
  26644. private _sceneRootNodesIndex;
  26645. /**
  26646. * Gets a boolean indicating if the node has been disposed
  26647. * @returns true if the node was disposed
  26648. */
  26649. isDisposed(): boolean;
  26650. /**
  26651. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26652. * @see https://doc.babylonjs.com/how_to/parenting
  26653. */
  26654. parent: Nullable<Node>;
  26655. private addToSceneRootNodes;
  26656. private removeFromSceneRootNodes;
  26657. private _animationPropertiesOverride;
  26658. /**
  26659. * Gets or sets the animation properties override
  26660. */
  26661. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26662. /**
  26663. * Gets a string idenfifying the name of the class
  26664. * @returns "Node" string
  26665. */
  26666. getClassName(): string;
  26667. /** @hidden */
  26668. readonly _isNode: boolean;
  26669. /**
  26670. * An event triggered when the mesh is disposed
  26671. */
  26672. onDisposeObservable: Observable<Node>;
  26673. private _onDisposeObserver;
  26674. /**
  26675. * Sets a callback that will be raised when the node will be disposed
  26676. */
  26677. onDispose: () => void;
  26678. /**
  26679. * Creates a new Node
  26680. * @param name the name and id to be given to this node
  26681. * @param scene the scene this node will be added to
  26682. * @param addToRootNodes the node will be added to scene.rootNodes
  26683. */
  26684. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26685. /**
  26686. * Gets the scene of the node
  26687. * @returns a scene
  26688. */
  26689. getScene(): Scene;
  26690. /**
  26691. * Gets the engine of the node
  26692. * @returns a Engine
  26693. */
  26694. getEngine(): Engine;
  26695. private _behaviors;
  26696. /**
  26697. * Attach a behavior to the node
  26698. * @see http://doc.babylonjs.com/features/behaviour
  26699. * @param behavior defines the behavior to attach
  26700. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26701. * @returns the current Node
  26702. */
  26703. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26704. /**
  26705. * Remove an attached behavior
  26706. * @see http://doc.babylonjs.com/features/behaviour
  26707. * @param behavior defines the behavior to attach
  26708. * @returns the current Node
  26709. */
  26710. removeBehavior(behavior: Behavior<Node>): Node;
  26711. /**
  26712. * Gets the list of attached behaviors
  26713. * @see http://doc.babylonjs.com/features/behaviour
  26714. */
  26715. readonly behaviors: Behavior<Node>[];
  26716. /**
  26717. * Gets an attached behavior by name
  26718. * @param name defines the name of the behavior to look for
  26719. * @see http://doc.babylonjs.com/features/behaviour
  26720. * @returns null if behavior was not found else the requested behavior
  26721. */
  26722. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26723. /**
  26724. * Returns the latest update of the World matrix
  26725. * @returns a Matrix
  26726. */
  26727. getWorldMatrix(): Matrix;
  26728. /** @hidden */
  26729. _getWorldMatrixDeterminant(): number;
  26730. /**
  26731. * Returns directly the latest state of the mesh World matrix.
  26732. * A Matrix is returned.
  26733. */
  26734. readonly worldMatrixFromCache: Matrix;
  26735. /** @hidden */
  26736. _initCache(): void;
  26737. /** @hidden */
  26738. updateCache(force?: boolean): void;
  26739. /** @hidden */
  26740. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26741. /** @hidden */
  26742. _updateCache(ignoreParentClass?: boolean): void;
  26743. /** @hidden */
  26744. _isSynchronized(): boolean;
  26745. /** @hidden */
  26746. _markSyncedWithParent(): void;
  26747. /** @hidden */
  26748. isSynchronizedWithParent(): boolean;
  26749. /** @hidden */
  26750. isSynchronized(): boolean;
  26751. /**
  26752. * Is this node ready to be used/rendered
  26753. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26754. * @return true if the node is ready
  26755. */
  26756. isReady(completeCheck?: boolean): boolean;
  26757. /**
  26758. * Is this node enabled?
  26759. * 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
  26760. * @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
  26761. * @return whether this node (and its parent) is enabled
  26762. */
  26763. isEnabled(checkAncestors?: boolean): boolean;
  26764. /** @hidden */
  26765. protected _syncParentEnabledState(): void;
  26766. /**
  26767. * Set the enabled state of this node
  26768. * @param value defines the new enabled state
  26769. */
  26770. setEnabled(value: boolean): void;
  26771. /**
  26772. * Is this node a descendant of the given node?
  26773. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26774. * @param ancestor defines the parent node to inspect
  26775. * @returns a boolean indicating if this node is a descendant of the given node
  26776. */
  26777. isDescendantOf(ancestor: Node): boolean;
  26778. /** @hidden */
  26779. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26780. /**
  26781. * Will return all nodes that have this node as ascendant
  26782. * @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
  26783. * @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
  26784. * @return all children nodes of all types
  26785. */
  26786. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26787. /**
  26788. * Get all child-meshes of this node
  26789. * @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)
  26790. * @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
  26791. * @returns an array of AbstractMesh
  26792. */
  26793. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26794. /**
  26795. * Get all direct children of this node
  26796. * @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
  26797. * @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)
  26798. * @returns an array of Node
  26799. */
  26800. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26801. /** @hidden */
  26802. _setReady(state: boolean): void;
  26803. /**
  26804. * Get an animation by name
  26805. * @param name defines the name of the animation to look for
  26806. * @returns null if not found else the requested animation
  26807. */
  26808. getAnimationByName(name: string): Nullable<Animation>;
  26809. /**
  26810. * Creates an animation range for this node
  26811. * @param name defines the name of the range
  26812. * @param from defines the starting key
  26813. * @param to defines the end key
  26814. */
  26815. createAnimationRange(name: string, from: number, to: number): void;
  26816. /**
  26817. * Delete a specific animation range
  26818. * @param name defines the name of the range to delete
  26819. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26820. */
  26821. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26822. /**
  26823. * Get an animation range by name
  26824. * @param name defines the name of the animation range to look for
  26825. * @returns null if not found else the requested animation range
  26826. */
  26827. getAnimationRange(name: string): Nullable<AnimationRange>;
  26828. /**
  26829. * Gets the list of all animation ranges defined on this node
  26830. * @returns an array
  26831. */
  26832. getAnimationRanges(): Nullable<AnimationRange>[];
  26833. /**
  26834. * Will start the animation sequence
  26835. * @param name defines the range frames for animation sequence
  26836. * @param loop defines if the animation should loop (false by default)
  26837. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26838. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26839. * @returns the object created for this animation. If range does not exist, it will return null
  26840. */
  26841. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26842. /**
  26843. * Serialize animation ranges into a JSON compatible object
  26844. * @returns serialization object
  26845. */
  26846. serializeAnimationRanges(): any;
  26847. /**
  26848. * Computes the world matrix of the node
  26849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26850. * @returns the world matrix
  26851. */
  26852. computeWorldMatrix(force?: boolean): Matrix;
  26853. /**
  26854. * Releases resources associated with this node.
  26855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26857. */
  26858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26859. /**
  26860. * Parse animation range data from a serialization object and store them into a given node
  26861. * @param node defines where to store the animation ranges
  26862. * @param parsedNode defines the serialization object to read data from
  26863. * @param scene defines the hosting scene
  26864. */
  26865. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26866. /**
  26867. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26868. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26869. * @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
  26870. * @returns the new bounding vectors
  26871. */
  26872. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26873. min: Vector3;
  26874. max: Vector3;
  26875. };
  26876. }
  26877. }
  26878. declare module BABYLON {
  26879. /**
  26880. * @hidden
  26881. */
  26882. export class _IAnimationState {
  26883. key: number;
  26884. repeatCount: number;
  26885. workValue?: any;
  26886. loopMode?: number;
  26887. offsetValue?: any;
  26888. highLimitValue?: any;
  26889. }
  26890. /**
  26891. * Class used to store any kind of animation
  26892. */
  26893. export class Animation {
  26894. /**Name of the animation */
  26895. name: string;
  26896. /**Property to animate */
  26897. targetProperty: string;
  26898. /**The frames per second of the animation */
  26899. framePerSecond: number;
  26900. /**The data type of the animation */
  26901. dataType: number;
  26902. /**The loop mode of the animation */
  26903. loopMode?: number | undefined;
  26904. /**Specifies if blending should be enabled */
  26905. enableBlending?: boolean | undefined;
  26906. /**
  26907. * Use matrix interpolation instead of using direct key value when animating matrices
  26908. */
  26909. static AllowMatricesInterpolation: boolean;
  26910. /**
  26911. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26912. */
  26913. static AllowMatrixDecomposeForInterpolation: boolean;
  26914. /**
  26915. * Stores the key frames of the animation
  26916. */
  26917. private _keys;
  26918. /**
  26919. * Stores the easing function of the animation
  26920. */
  26921. private _easingFunction;
  26922. /**
  26923. * @hidden Internal use only
  26924. */
  26925. _runtimeAnimations: RuntimeAnimation[];
  26926. /**
  26927. * The set of event that will be linked to this animation
  26928. */
  26929. private _events;
  26930. /**
  26931. * Stores an array of target property paths
  26932. */
  26933. targetPropertyPath: string[];
  26934. /**
  26935. * Stores the blending speed of the animation
  26936. */
  26937. blendingSpeed: number;
  26938. /**
  26939. * Stores the animation ranges for the animation
  26940. */
  26941. private _ranges;
  26942. /**
  26943. * @hidden Internal use
  26944. */
  26945. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26946. /**
  26947. * Sets up an animation
  26948. * @param property The property to animate
  26949. * @param animationType The animation type to apply
  26950. * @param framePerSecond The frames per second of the animation
  26951. * @param easingFunction The easing function used in the animation
  26952. * @returns The created animation
  26953. */
  26954. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26955. /**
  26956. * Create and start an animation on a node
  26957. * @param name defines the name of the global animation that will be run on all nodes
  26958. * @param node defines the root node where the animation will take place
  26959. * @param targetProperty defines property to animate
  26960. * @param framePerSecond defines the number of frame per second yo use
  26961. * @param totalFrame defines the number of frames in total
  26962. * @param from defines the initial value
  26963. * @param to defines the final value
  26964. * @param loopMode defines which loop mode you want to use (off by default)
  26965. * @param easingFunction defines the easing function to use (linear by default)
  26966. * @param onAnimationEnd defines the callback to call when animation end
  26967. * @returns the animatable created for this animation
  26968. */
  26969. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26970. /**
  26971. * Create and start an animation on a node and its descendants
  26972. * @param name defines the name of the global animation that will be run on all nodes
  26973. * @param node defines the root node where the animation will take place
  26974. * @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
  26975. * @param targetProperty defines property to animate
  26976. * @param framePerSecond defines the number of frame per second to use
  26977. * @param totalFrame defines the number of frames in total
  26978. * @param from defines the initial value
  26979. * @param to defines the final value
  26980. * @param loopMode defines which loop mode you want to use (off by default)
  26981. * @param easingFunction defines the easing function to use (linear by default)
  26982. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26983. * @returns the list of animatables created for all nodes
  26984. * @example https://www.babylonjs-playground.com/#MH0VLI
  26985. */
  26986. 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[]>;
  26987. /**
  26988. * Creates a new animation, merges it with the existing animations and starts it
  26989. * @param name Name of the animation
  26990. * @param node Node which contains the scene that begins the animations
  26991. * @param targetProperty Specifies which property to animate
  26992. * @param framePerSecond The frames per second of the animation
  26993. * @param totalFrame The total number of frames
  26994. * @param from The frame at the beginning of the animation
  26995. * @param to The frame at the end of the animation
  26996. * @param loopMode Specifies the loop mode of the animation
  26997. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26998. * @param onAnimationEnd Callback to run once the animation is complete
  26999. * @returns Nullable animation
  27000. */
  27001. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27002. /**
  27003. * Transition property of an host to the target Value
  27004. * @param property The property to transition
  27005. * @param targetValue The target Value of the property
  27006. * @param host The object where the property to animate belongs
  27007. * @param scene Scene used to run the animation
  27008. * @param frameRate Framerate (in frame/s) to use
  27009. * @param transition The transition type we want to use
  27010. * @param duration The duration of the animation, in milliseconds
  27011. * @param onAnimationEnd Callback trigger at the end of the animation
  27012. * @returns Nullable animation
  27013. */
  27014. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27015. /**
  27016. * Return the array of runtime animations currently using this animation
  27017. */
  27018. readonly runtimeAnimations: RuntimeAnimation[];
  27019. /**
  27020. * Specifies if any of the runtime animations are currently running
  27021. */
  27022. readonly hasRunningRuntimeAnimations: boolean;
  27023. /**
  27024. * Initializes the animation
  27025. * @param name Name of the animation
  27026. * @param targetProperty Property to animate
  27027. * @param framePerSecond The frames per second of the animation
  27028. * @param dataType The data type of the animation
  27029. * @param loopMode The loop mode of the animation
  27030. * @param enableBlending Specifies if blending should be enabled
  27031. */
  27032. constructor(
  27033. /**Name of the animation */
  27034. name: string,
  27035. /**Property to animate */
  27036. targetProperty: string,
  27037. /**The frames per second of the animation */
  27038. framePerSecond: number,
  27039. /**The data type of the animation */
  27040. dataType: number,
  27041. /**The loop mode of the animation */
  27042. loopMode?: number | undefined,
  27043. /**Specifies if blending should be enabled */
  27044. enableBlending?: boolean | undefined);
  27045. /**
  27046. * Converts the animation to a string
  27047. * @param fullDetails support for multiple levels of logging within scene loading
  27048. * @returns String form of the animation
  27049. */
  27050. toString(fullDetails?: boolean): string;
  27051. /**
  27052. * Add an event to this animation
  27053. * @param event Event to add
  27054. */
  27055. addEvent(event: AnimationEvent): void;
  27056. /**
  27057. * Remove all events found at the given frame
  27058. * @param frame The frame to remove events from
  27059. */
  27060. removeEvents(frame: number): void;
  27061. /**
  27062. * Retrieves all the events from the animation
  27063. * @returns Events from the animation
  27064. */
  27065. getEvents(): AnimationEvent[];
  27066. /**
  27067. * Creates an animation range
  27068. * @param name Name of the animation range
  27069. * @param from Starting frame of the animation range
  27070. * @param to Ending frame of the animation
  27071. */
  27072. createRange(name: string, from: number, to: number): void;
  27073. /**
  27074. * Deletes an animation range by name
  27075. * @param name Name of the animation range to delete
  27076. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27077. */
  27078. deleteRange(name: string, deleteFrames?: boolean): void;
  27079. /**
  27080. * Gets the animation range by name, or null if not defined
  27081. * @param name Name of the animation range
  27082. * @returns Nullable animation range
  27083. */
  27084. getRange(name: string): Nullable<AnimationRange>;
  27085. /**
  27086. * Gets the key frames from the animation
  27087. * @returns The key frames of the animation
  27088. */
  27089. getKeys(): Array<IAnimationKey>;
  27090. /**
  27091. * Gets the highest frame rate of the animation
  27092. * @returns Highest frame rate of the animation
  27093. */
  27094. getHighestFrame(): number;
  27095. /**
  27096. * Gets the easing function of the animation
  27097. * @returns Easing function of the animation
  27098. */
  27099. getEasingFunction(): IEasingFunction;
  27100. /**
  27101. * Sets the easing function of the animation
  27102. * @param easingFunction A custom mathematical formula for animation
  27103. */
  27104. setEasingFunction(easingFunction: EasingFunction): void;
  27105. /**
  27106. * Interpolates a scalar linearly
  27107. * @param startValue Start value of the animation curve
  27108. * @param endValue End value of the animation curve
  27109. * @param gradient Scalar amount to interpolate
  27110. * @returns Interpolated scalar value
  27111. */
  27112. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27113. /**
  27114. * Interpolates a scalar cubically
  27115. * @param startValue Start value of the animation curve
  27116. * @param outTangent End tangent of the animation
  27117. * @param endValue End value of the animation curve
  27118. * @param inTangent Start tangent of the animation curve
  27119. * @param gradient Scalar amount to interpolate
  27120. * @returns Interpolated scalar value
  27121. */
  27122. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27123. /**
  27124. * Interpolates a quaternion using a spherical linear interpolation
  27125. * @param startValue Start value of the animation curve
  27126. * @param endValue End value of the animation curve
  27127. * @param gradient Scalar amount to interpolate
  27128. * @returns Interpolated quaternion value
  27129. */
  27130. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27131. /**
  27132. * Interpolates a quaternion cubically
  27133. * @param startValue Start value of the animation curve
  27134. * @param outTangent End tangent of the animation curve
  27135. * @param endValue End value of the animation curve
  27136. * @param inTangent Start tangent of the animation curve
  27137. * @param gradient Scalar amount to interpolate
  27138. * @returns Interpolated quaternion value
  27139. */
  27140. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27141. /**
  27142. * Interpolates a Vector3 linearl
  27143. * @param startValue Start value of the animation curve
  27144. * @param endValue End value of the animation curve
  27145. * @param gradient Scalar amount to interpolate
  27146. * @returns Interpolated scalar value
  27147. */
  27148. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27149. /**
  27150. * Interpolates a Vector3 cubically
  27151. * @param startValue Start value of the animation curve
  27152. * @param outTangent End tangent of the animation
  27153. * @param endValue End value of the animation curve
  27154. * @param inTangent Start tangent of the animation curve
  27155. * @param gradient Scalar amount to interpolate
  27156. * @returns InterpolatedVector3 value
  27157. */
  27158. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27159. /**
  27160. * Interpolates a Vector2 linearly
  27161. * @param startValue Start value of the animation curve
  27162. * @param endValue End value of the animation curve
  27163. * @param gradient Scalar amount to interpolate
  27164. * @returns Interpolated Vector2 value
  27165. */
  27166. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27167. /**
  27168. * Interpolates a Vector2 cubically
  27169. * @param startValue Start value of the animation curve
  27170. * @param outTangent End tangent of the animation
  27171. * @param endValue End value of the animation curve
  27172. * @param inTangent Start tangent of the animation curve
  27173. * @param gradient Scalar amount to interpolate
  27174. * @returns Interpolated Vector2 value
  27175. */
  27176. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27177. /**
  27178. * Interpolates a size linearly
  27179. * @param startValue Start value of the animation curve
  27180. * @param endValue End value of the animation curve
  27181. * @param gradient Scalar amount to interpolate
  27182. * @returns Interpolated Size value
  27183. */
  27184. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27185. /**
  27186. * Interpolates a Color3 linearly
  27187. * @param startValue Start value of the animation curve
  27188. * @param endValue End value of the animation curve
  27189. * @param gradient Scalar amount to interpolate
  27190. * @returns Interpolated Color3 value
  27191. */
  27192. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27193. /**
  27194. * @hidden Internal use only
  27195. */
  27196. _getKeyValue(value: any): any;
  27197. /**
  27198. * @hidden Internal use only
  27199. */
  27200. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27201. /**
  27202. * Defines the function to use to interpolate matrices
  27203. * @param startValue defines the start matrix
  27204. * @param endValue defines the end matrix
  27205. * @param gradient defines the gradient between both matrices
  27206. * @param result defines an optional target matrix where to store the interpolation
  27207. * @returns the interpolated matrix
  27208. */
  27209. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27210. /**
  27211. * Makes a copy of the animation
  27212. * @returns Cloned animation
  27213. */
  27214. clone(): Animation;
  27215. /**
  27216. * Sets the key frames of the animation
  27217. * @param values The animation key frames to set
  27218. */
  27219. setKeys(values: Array<IAnimationKey>): void;
  27220. /**
  27221. * Serializes the animation to an object
  27222. * @returns Serialized object
  27223. */
  27224. serialize(): any;
  27225. /**
  27226. * Float animation type
  27227. */
  27228. private static _ANIMATIONTYPE_FLOAT;
  27229. /**
  27230. * Vector3 animation type
  27231. */
  27232. private static _ANIMATIONTYPE_VECTOR3;
  27233. /**
  27234. * Quaternion animation type
  27235. */
  27236. private static _ANIMATIONTYPE_QUATERNION;
  27237. /**
  27238. * Matrix animation type
  27239. */
  27240. private static _ANIMATIONTYPE_MATRIX;
  27241. /**
  27242. * Color3 animation type
  27243. */
  27244. private static _ANIMATIONTYPE_COLOR3;
  27245. /**
  27246. * Vector2 animation type
  27247. */
  27248. private static _ANIMATIONTYPE_VECTOR2;
  27249. /**
  27250. * Size animation type
  27251. */
  27252. private static _ANIMATIONTYPE_SIZE;
  27253. /**
  27254. * Relative Loop Mode
  27255. */
  27256. private static _ANIMATIONLOOPMODE_RELATIVE;
  27257. /**
  27258. * Cycle Loop Mode
  27259. */
  27260. private static _ANIMATIONLOOPMODE_CYCLE;
  27261. /**
  27262. * Constant Loop Mode
  27263. */
  27264. private static _ANIMATIONLOOPMODE_CONSTANT;
  27265. /**
  27266. * Get the float animation type
  27267. */
  27268. static readonly ANIMATIONTYPE_FLOAT: number;
  27269. /**
  27270. * Get the Vector3 animation type
  27271. */
  27272. static readonly ANIMATIONTYPE_VECTOR3: number;
  27273. /**
  27274. * Get the Vector2 animation type
  27275. */
  27276. static readonly ANIMATIONTYPE_VECTOR2: number;
  27277. /**
  27278. * Get the Size animation type
  27279. */
  27280. static readonly ANIMATIONTYPE_SIZE: number;
  27281. /**
  27282. * Get the Quaternion animation type
  27283. */
  27284. static readonly ANIMATIONTYPE_QUATERNION: number;
  27285. /**
  27286. * Get the Matrix animation type
  27287. */
  27288. static readonly ANIMATIONTYPE_MATRIX: number;
  27289. /**
  27290. * Get the Color3 animation type
  27291. */
  27292. static readonly ANIMATIONTYPE_COLOR3: number;
  27293. /**
  27294. * Get the Relative Loop Mode
  27295. */
  27296. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27297. /**
  27298. * Get the Cycle Loop Mode
  27299. */
  27300. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27301. /**
  27302. * Get the Constant Loop Mode
  27303. */
  27304. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27305. /** @hidden */
  27306. static _UniversalLerp(left: any, right: any, amount: number): any;
  27307. /**
  27308. * Parses an animation object and creates an animation
  27309. * @param parsedAnimation Parsed animation object
  27310. * @returns Animation object
  27311. */
  27312. static Parse(parsedAnimation: any): Animation;
  27313. /**
  27314. * Appends the serialized animations from the source animations
  27315. * @param source Source containing the animations
  27316. * @param destination Target to store the animations
  27317. */
  27318. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27319. }
  27320. }
  27321. declare module BABYLON {
  27322. /**
  27323. * Interface containing an array of animations
  27324. */
  27325. export interface IAnimatable {
  27326. /**
  27327. * Array of animations
  27328. */
  27329. animations: Nullable<Array<Animation>>;
  27330. }
  27331. }
  27332. declare module BABYLON {
  27333. /**
  27334. * This represents all the required information to add a fresnel effect on a material:
  27335. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27336. */
  27337. export class FresnelParameters {
  27338. private _isEnabled;
  27339. /**
  27340. * Define if the fresnel effect is enable or not.
  27341. */
  27342. isEnabled: boolean;
  27343. /**
  27344. * Define the color used on edges (grazing angle)
  27345. */
  27346. leftColor: Color3;
  27347. /**
  27348. * Define the color used on center
  27349. */
  27350. rightColor: Color3;
  27351. /**
  27352. * Define bias applied to computed fresnel term
  27353. */
  27354. bias: number;
  27355. /**
  27356. * Defined the power exponent applied to fresnel term
  27357. */
  27358. power: number;
  27359. /**
  27360. * Clones the current fresnel and its valuues
  27361. * @returns a clone fresnel configuration
  27362. */
  27363. clone(): FresnelParameters;
  27364. /**
  27365. * Serializes the current fresnel parameters to a JSON representation.
  27366. * @return the JSON serialization
  27367. */
  27368. serialize(): any;
  27369. /**
  27370. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27371. * @param parsedFresnelParameters Define the JSON representation
  27372. * @returns the parsed parameters
  27373. */
  27374. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27375. }
  27376. }
  27377. declare module BABYLON {
  27378. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27379. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27380. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27381. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27382. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27383. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27384. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27385. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27386. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27387. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27388. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27389. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27390. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27391. /**
  27392. * Decorator used to define property that can be serialized as reference to a camera
  27393. * @param sourceName defines the name of the property to decorate
  27394. */
  27395. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27396. /**
  27397. * Class used to help serialization objects
  27398. */
  27399. export class SerializationHelper {
  27400. /** @hidden */
  27401. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27402. /** @hidden */
  27403. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27404. /** @hidden */
  27405. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27406. /** @hidden */
  27407. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27408. /**
  27409. * Appends the serialized animations from the source animations
  27410. * @param source Source containing the animations
  27411. * @param destination Target to store the animations
  27412. */
  27413. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27414. /**
  27415. * Static function used to serialized a specific entity
  27416. * @param entity defines the entity to serialize
  27417. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27418. * @returns a JSON compatible object representing the serialization of the entity
  27419. */
  27420. static Serialize<T>(entity: T, serializationObject?: any): any;
  27421. /**
  27422. * Creates a new entity from a serialization data object
  27423. * @param creationFunction defines a function used to instanciated the new entity
  27424. * @param source defines the source serialization data
  27425. * @param scene defines the hosting scene
  27426. * @param rootUrl defines the root url for resources
  27427. * @returns a new entity
  27428. */
  27429. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27430. /**
  27431. * Clones an object
  27432. * @param creationFunction defines the function used to instanciate the new object
  27433. * @param source defines the source object
  27434. * @returns the cloned object
  27435. */
  27436. static Clone<T>(creationFunction: () => T, source: T): T;
  27437. /**
  27438. * Instanciates a new object based on a source one (some data will be shared between both object)
  27439. * @param creationFunction defines the function used to instanciate the new object
  27440. * @param source defines the source object
  27441. * @returns the new object
  27442. */
  27443. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27444. }
  27445. }
  27446. declare module BABYLON {
  27447. /**
  27448. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27449. */
  27450. export interface CubeMapInfo {
  27451. /**
  27452. * The pixel array for the front face.
  27453. * This is stored in format, left to right, up to down format.
  27454. */
  27455. front: Nullable<ArrayBufferView>;
  27456. /**
  27457. * The pixel array for the back face.
  27458. * This is stored in format, left to right, up to down format.
  27459. */
  27460. back: Nullable<ArrayBufferView>;
  27461. /**
  27462. * The pixel array for the left face.
  27463. * This is stored in format, left to right, up to down format.
  27464. */
  27465. left: Nullable<ArrayBufferView>;
  27466. /**
  27467. * The pixel array for the right face.
  27468. * This is stored in format, left to right, up to down format.
  27469. */
  27470. right: Nullable<ArrayBufferView>;
  27471. /**
  27472. * The pixel array for the up face.
  27473. * This is stored in format, left to right, up to down format.
  27474. */
  27475. up: Nullable<ArrayBufferView>;
  27476. /**
  27477. * The pixel array for the down face.
  27478. * This is stored in format, left to right, up to down format.
  27479. */
  27480. down: Nullable<ArrayBufferView>;
  27481. /**
  27482. * The size of the cubemap stored.
  27483. *
  27484. * Each faces will be size * size pixels.
  27485. */
  27486. size: number;
  27487. /**
  27488. * The format of the texture.
  27489. *
  27490. * RGBA, RGB.
  27491. */
  27492. format: number;
  27493. /**
  27494. * The type of the texture data.
  27495. *
  27496. * UNSIGNED_INT, FLOAT.
  27497. */
  27498. type: number;
  27499. /**
  27500. * Specifies whether the texture is in gamma space.
  27501. */
  27502. gammaSpace: boolean;
  27503. }
  27504. /**
  27505. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27506. */
  27507. export class PanoramaToCubeMapTools {
  27508. private static FACE_FRONT;
  27509. private static FACE_BACK;
  27510. private static FACE_RIGHT;
  27511. private static FACE_LEFT;
  27512. private static FACE_DOWN;
  27513. private static FACE_UP;
  27514. /**
  27515. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27516. *
  27517. * @param float32Array The source data.
  27518. * @param inputWidth The width of the input panorama.
  27519. * @param inputHeight The height of the input panorama.
  27520. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27521. * @return The cubemap data
  27522. */
  27523. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27524. private static CreateCubemapTexture;
  27525. private static CalcProjectionSpherical;
  27526. }
  27527. }
  27528. declare module BABYLON {
  27529. /**
  27530. * Helper class dealing with the extraction of spherical polynomial dataArray
  27531. * from a cube map.
  27532. */
  27533. export class CubeMapToSphericalPolynomialTools {
  27534. private static FileFaces;
  27535. /**
  27536. * Converts a texture to the according Spherical Polynomial data.
  27537. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27538. *
  27539. * @param texture The texture to extract the information from.
  27540. * @return The Spherical Polynomial data.
  27541. */
  27542. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27543. /**
  27544. * Converts a cubemap to the according Spherical Polynomial data.
  27545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27546. *
  27547. * @param cubeInfo The Cube map to extract the information from.
  27548. * @return The Spherical Polynomial data.
  27549. */
  27550. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27551. }
  27552. }
  27553. declare module BABYLON {
  27554. /**
  27555. * Class used to manipulate GUIDs
  27556. */
  27557. export class GUID {
  27558. /**
  27559. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27560. * Be aware Math.random() could cause collisions, but:
  27561. * "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"
  27562. * @returns a pseudo random id
  27563. */
  27564. static RandomId(): string;
  27565. }
  27566. }
  27567. declare module BABYLON {
  27568. /**
  27569. * Base class of all the textures in babylon.
  27570. * It groups all the common properties the materials, post process, lights... might need
  27571. * in order to make a correct use of the texture.
  27572. */
  27573. export class BaseTexture implements IAnimatable {
  27574. /**
  27575. * Default anisotropic filtering level for the application.
  27576. * It is set to 4 as a good tradeoff between perf and quality.
  27577. */
  27578. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27579. /**
  27580. * Gets or sets the unique id of the texture
  27581. */
  27582. uniqueId: number;
  27583. /**
  27584. * Define the name of the texture.
  27585. */
  27586. name: string;
  27587. /**
  27588. * Gets or sets an object used to store user defined information.
  27589. */
  27590. metadata: any;
  27591. /**
  27592. * For internal use only. Please do not use.
  27593. */
  27594. reservedDataStore: any;
  27595. private _hasAlpha;
  27596. /**
  27597. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27598. */
  27599. hasAlpha: boolean;
  27600. /**
  27601. * Defines if the alpha value should be determined via the rgb values.
  27602. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27603. */
  27604. getAlphaFromRGB: boolean;
  27605. /**
  27606. * Intensity or strength of the texture.
  27607. * It is commonly used by materials to fine tune the intensity of the texture
  27608. */
  27609. level: number;
  27610. /**
  27611. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27612. * This is part of the texture as textures usually maps to one uv set.
  27613. */
  27614. coordinatesIndex: number;
  27615. private _coordinatesMode;
  27616. /**
  27617. * How a texture is mapped.
  27618. *
  27619. * | Value | Type | Description |
  27620. * | ----- | ----------------------------------- | ----------- |
  27621. * | 0 | EXPLICIT_MODE | |
  27622. * | 1 | SPHERICAL_MODE | |
  27623. * | 2 | PLANAR_MODE | |
  27624. * | 3 | CUBIC_MODE | |
  27625. * | 4 | PROJECTION_MODE | |
  27626. * | 5 | SKYBOX_MODE | |
  27627. * | 6 | INVCUBIC_MODE | |
  27628. * | 7 | EQUIRECTANGULAR_MODE | |
  27629. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27630. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27631. */
  27632. coordinatesMode: number;
  27633. /**
  27634. * | Value | Type | Description |
  27635. * | ----- | ------------------ | ----------- |
  27636. * | 0 | CLAMP_ADDRESSMODE | |
  27637. * | 1 | WRAP_ADDRESSMODE | |
  27638. * | 2 | MIRROR_ADDRESSMODE | |
  27639. */
  27640. wrapU: number;
  27641. /**
  27642. * | Value | Type | Description |
  27643. * | ----- | ------------------ | ----------- |
  27644. * | 0 | CLAMP_ADDRESSMODE | |
  27645. * | 1 | WRAP_ADDRESSMODE | |
  27646. * | 2 | MIRROR_ADDRESSMODE | |
  27647. */
  27648. wrapV: number;
  27649. /**
  27650. * | Value | Type | Description |
  27651. * | ----- | ------------------ | ----------- |
  27652. * | 0 | CLAMP_ADDRESSMODE | |
  27653. * | 1 | WRAP_ADDRESSMODE | |
  27654. * | 2 | MIRROR_ADDRESSMODE | |
  27655. */
  27656. wrapR: number;
  27657. /**
  27658. * With compliant hardware and browser (supporting anisotropic filtering)
  27659. * this defines the level of anisotropic filtering in the texture.
  27660. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27661. */
  27662. anisotropicFilteringLevel: number;
  27663. /**
  27664. * Define if the texture is a cube texture or if false a 2d texture.
  27665. */
  27666. isCube: boolean;
  27667. /**
  27668. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27669. */
  27670. is3D: boolean;
  27671. /**
  27672. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27673. * HDR texture are usually stored in linear space.
  27674. * This only impacts the PBR and Background materials
  27675. */
  27676. gammaSpace: boolean;
  27677. /**
  27678. * Gets whether or not the texture contains RGBD data.
  27679. */
  27680. readonly isRGBD: boolean;
  27681. /**
  27682. * Is Z inverted in the texture (useful in a cube texture).
  27683. */
  27684. invertZ: boolean;
  27685. /**
  27686. * Are mip maps generated for this texture or not.
  27687. */
  27688. readonly noMipmap: boolean;
  27689. /**
  27690. * @hidden
  27691. */
  27692. lodLevelInAlpha: boolean;
  27693. /**
  27694. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27695. */
  27696. lodGenerationOffset: number;
  27697. /**
  27698. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27699. */
  27700. lodGenerationScale: number;
  27701. /**
  27702. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27703. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27704. * average roughness values.
  27705. */
  27706. linearSpecularLOD: boolean;
  27707. /**
  27708. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27709. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27710. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27711. */
  27712. irradianceTexture: Nullable<BaseTexture>;
  27713. /**
  27714. * Define if the texture is a render target.
  27715. */
  27716. isRenderTarget: boolean;
  27717. /**
  27718. * Define the unique id of the texture in the scene.
  27719. */
  27720. readonly uid: string;
  27721. /**
  27722. * Return a string representation of the texture.
  27723. * @returns the texture as a string
  27724. */
  27725. toString(): string;
  27726. /**
  27727. * Get the class name of the texture.
  27728. * @returns "BaseTexture"
  27729. */
  27730. getClassName(): string;
  27731. /**
  27732. * Define the list of animation attached to the texture.
  27733. */
  27734. animations: Animation[];
  27735. /**
  27736. * An event triggered when the texture is disposed.
  27737. */
  27738. onDisposeObservable: Observable<BaseTexture>;
  27739. private _onDisposeObserver;
  27740. /**
  27741. * Callback triggered when the texture has been disposed.
  27742. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27743. */
  27744. onDispose: () => void;
  27745. /**
  27746. * Define the current state of the loading sequence when in delayed load mode.
  27747. */
  27748. delayLoadState: number;
  27749. private _scene;
  27750. /** @hidden */
  27751. _texture: Nullable<InternalTexture>;
  27752. private _uid;
  27753. /**
  27754. * Define if the texture is preventinga material to render or not.
  27755. * If not and the texture is not ready, the engine will use a default black texture instead.
  27756. */
  27757. readonly isBlocking: boolean;
  27758. /**
  27759. * Instantiates a new BaseTexture.
  27760. * Base class of all the textures in babylon.
  27761. * It groups all the common properties the materials, post process, lights... might need
  27762. * in order to make a correct use of the texture.
  27763. * @param scene Define the scene the texture blongs to
  27764. */
  27765. constructor(scene: Nullable<Scene>);
  27766. /**
  27767. * Get the scene the texture belongs to.
  27768. * @returns the scene or null if undefined
  27769. */
  27770. getScene(): Nullable<Scene>;
  27771. /**
  27772. * Get the texture transform matrix used to offset tile the texture for istance.
  27773. * @returns the transformation matrix
  27774. */
  27775. getTextureMatrix(): Matrix;
  27776. /**
  27777. * Get the texture reflection matrix used to rotate/transform the reflection.
  27778. * @returns the reflection matrix
  27779. */
  27780. getReflectionTextureMatrix(): Matrix;
  27781. /**
  27782. * Get the underlying lower level texture from Babylon.
  27783. * @returns the insternal texture
  27784. */
  27785. getInternalTexture(): Nullable<InternalTexture>;
  27786. /**
  27787. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27788. * @returns true if ready or not blocking
  27789. */
  27790. isReadyOrNotBlocking(): boolean;
  27791. /**
  27792. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27793. * @returns true if fully ready
  27794. */
  27795. isReady(): boolean;
  27796. private _cachedSize;
  27797. /**
  27798. * Get the size of the texture.
  27799. * @returns the texture size.
  27800. */
  27801. getSize(): ISize;
  27802. /**
  27803. * Get the base size of the texture.
  27804. * It can be different from the size if the texture has been resized for POT for instance
  27805. * @returns the base size
  27806. */
  27807. getBaseSize(): ISize;
  27808. /**
  27809. * Update the sampling mode of the texture.
  27810. * Default is Trilinear mode.
  27811. *
  27812. * | Value | Type | Description |
  27813. * | ----- | ------------------ | ----------- |
  27814. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27815. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27816. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27817. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27818. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27819. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27820. * | 7 | NEAREST_LINEAR | |
  27821. * | 8 | NEAREST_NEAREST | |
  27822. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27823. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27824. * | 11 | LINEAR_LINEAR | |
  27825. * | 12 | LINEAR_NEAREST | |
  27826. *
  27827. * > _mag_: magnification filter (close to the viewer)
  27828. * > _min_: minification filter (far from the viewer)
  27829. * > _mip_: filter used between mip map levels
  27830. *@param samplingMode Define the new sampling mode of the texture
  27831. */
  27832. updateSamplingMode(samplingMode: number): void;
  27833. /**
  27834. * Scales the texture if is `canRescale()`
  27835. * @param ratio the resize factor we want to use to rescale
  27836. */
  27837. scale(ratio: number): void;
  27838. /**
  27839. * Get if the texture can rescale.
  27840. */
  27841. readonly canRescale: boolean;
  27842. /** @hidden */
  27843. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27844. /** @hidden */
  27845. _rebuild(): void;
  27846. /**
  27847. * Triggers the load sequence in delayed load mode.
  27848. */
  27849. delayLoad(): void;
  27850. /**
  27851. * Clones the texture.
  27852. * @returns the cloned texture
  27853. */
  27854. clone(): Nullable<BaseTexture>;
  27855. /**
  27856. * Get the texture underlying type (INT, FLOAT...)
  27857. */
  27858. readonly textureType: number;
  27859. /**
  27860. * Get the texture underlying format (RGB, RGBA...)
  27861. */
  27862. readonly textureFormat: number;
  27863. /**
  27864. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27865. * This will returns an RGBA array buffer containing either in values (0-255) or
  27866. * float values (0-1) depending of the underlying buffer type.
  27867. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27868. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27869. * @param buffer defines a user defined buffer to fill with data (can be null)
  27870. * @returns The Array buffer containing the pixels data.
  27871. */
  27872. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27873. /**
  27874. * Release and destroy the underlying lower level texture aka internalTexture.
  27875. */
  27876. releaseInternalTexture(): void;
  27877. /**
  27878. * Get the polynomial representation of the texture data.
  27879. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27880. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27881. */
  27882. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27883. /** @hidden */
  27884. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27885. /** @hidden */
  27886. readonly _lodTextureMid: Nullable<BaseTexture>;
  27887. /** @hidden */
  27888. readonly _lodTextureLow: Nullable<BaseTexture>;
  27889. /**
  27890. * Dispose the texture and release its associated resources.
  27891. */
  27892. dispose(): void;
  27893. /**
  27894. * Serialize the texture into a JSON representation that can be parsed later on.
  27895. * @returns the JSON representation of the texture
  27896. */
  27897. serialize(): any;
  27898. /**
  27899. * Helper function to be called back once a list of texture contains only ready textures.
  27900. * @param textures Define the list of textures to wait for
  27901. * @param callback Define the callback triggered once the entire list will be ready
  27902. */
  27903. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27904. }
  27905. }
  27906. declare module BABYLON {
  27907. /**
  27908. * Class used to store data associated with WebGL texture data for the engine
  27909. * This class should not be used directly
  27910. */
  27911. export class InternalTexture {
  27912. /** @hidden */
  27913. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27914. /**
  27915. * The source of the texture data is unknown
  27916. */
  27917. static DATASOURCE_UNKNOWN: number;
  27918. /**
  27919. * Texture data comes from an URL
  27920. */
  27921. static DATASOURCE_URL: number;
  27922. /**
  27923. * Texture data is only used for temporary storage
  27924. */
  27925. static DATASOURCE_TEMP: number;
  27926. /**
  27927. * Texture data comes from raw data (ArrayBuffer)
  27928. */
  27929. static DATASOURCE_RAW: number;
  27930. /**
  27931. * Texture content is dynamic (video or dynamic texture)
  27932. */
  27933. static DATASOURCE_DYNAMIC: number;
  27934. /**
  27935. * Texture content is generated by rendering to it
  27936. */
  27937. static DATASOURCE_RENDERTARGET: number;
  27938. /**
  27939. * Texture content is part of a multi render target process
  27940. */
  27941. static DATASOURCE_MULTIRENDERTARGET: number;
  27942. /**
  27943. * Texture data comes from a cube data file
  27944. */
  27945. static DATASOURCE_CUBE: number;
  27946. /**
  27947. * Texture data comes from a raw cube data
  27948. */
  27949. static DATASOURCE_CUBERAW: number;
  27950. /**
  27951. * Texture data come from a prefiltered cube data file
  27952. */
  27953. static DATASOURCE_CUBEPREFILTERED: number;
  27954. /**
  27955. * Texture content is raw 3D data
  27956. */
  27957. static DATASOURCE_RAW3D: number;
  27958. /**
  27959. * Texture content is a depth texture
  27960. */
  27961. static DATASOURCE_DEPTHTEXTURE: number;
  27962. /**
  27963. * Texture data comes from a raw cube data encoded with RGBD
  27964. */
  27965. static DATASOURCE_CUBERAW_RGBD: number;
  27966. /**
  27967. * Defines if the texture is ready
  27968. */
  27969. isReady: boolean;
  27970. /**
  27971. * Defines if the texture is a cube texture
  27972. */
  27973. isCube: boolean;
  27974. /**
  27975. * Defines if the texture contains 3D data
  27976. */
  27977. is3D: boolean;
  27978. /**
  27979. * Defines if the texture contains multiview data
  27980. */
  27981. isMultiview: boolean;
  27982. /**
  27983. * Gets the URL used to load this texture
  27984. */
  27985. url: string;
  27986. /**
  27987. * Gets the sampling mode of the texture
  27988. */
  27989. samplingMode: number;
  27990. /**
  27991. * Gets a boolean indicating if the texture needs mipmaps generation
  27992. */
  27993. generateMipMaps: boolean;
  27994. /**
  27995. * Gets the number of samples used by the texture (WebGL2+ only)
  27996. */
  27997. samples: number;
  27998. /**
  27999. * Gets the type of the texture (int, float...)
  28000. */
  28001. type: number;
  28002. /**
  28003. * Gets the format of the texture (RGB, RGBA...)
  28004. */
  28005. format: number;
  28006. /**
  28007. * Observable called when the texture is loaded
  28008. */
  28009. onLoadedObservable: Observable<InternalTexture>;
  28010. /**
  28011. * Gets the width of the texture
  28012. */
  28013. width: number;
  28014. /**
  28015. * Gets the height of the texture
  28016. */
  28017. height: number;
  28018. /**
  28019. * Gets the depth of the texture
  28020. */
  28021. depth: number;
  28022. /**
  28023. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28024. */
  28025. baseWidth: number;
  28026. /**
  28027. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28028. */
  28029. baseHeight: number;
  28030. /**
  28031. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28032. */
  28033. baseDepth: number;
  28034. /**
  28035. * Gets a boolean indicating if the texture is inverted on Y axis
  28036. */
  28037. invertY: boolean;
  28038. /** @hidden */
  28039. _invertVScale: boolean;
  28040. /** @hidden */
  28041. _associatedChannel: number;
  28042. /** @hidden */
  28043. _dataSource: number;
  28044. /** @hidden */
  28045. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28046. /** @hidden */
  28047. _bufferView: Nullable<ArrayBufferView>;
  28048. /** @hidden */
  28049. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28050. /** @hidden */
  28051. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28052. /** @hidden */
  28053. _size: number;
  28054. /** @hidden */
  28055. _extension: string;
  28056. /** @hidden */
  28057. _files: Nullable<string[]>;
  28058. /** @hidden */
  28059. _workingCanvas: Nullable<HTMLCanvasElement>;
  28060. /** @hidden */
  28061. _workingContext: Nullable<CanvasRenderingContext2D>;
  28062. /** @hidden */
  28063. _framebuffer: Nullable<WebGLFramebuffer>;
  28064. /** @hidden */
  28065. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28066. /** @hidden */
  28067. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28068. /** @hidden */
  28069. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28070. /** @hidden */
  28071. _attachments: Nullable<number[]>;
  28072. /** @hidden */
  28073. _cachedCoordinatesMode: Nullable<number>;
  28074. /** @hidden */
  28075. _cachedWrapU: Nullable<number>;
  28076. /** @hidden */
  28077. _cachedWrapV: Nullable<number>;
  28078. /** @hidden */
  28079. _cachedWrapR: Nullable<number>;
  28080. /** @hidden */
  28081. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28082. /** @hidden */
  28083. _isDisabled: boolean;
  28084. /** @hidden */
  28085. _compression: Nullable<string>;
  28086. /** @hidden */
  28087. _generateStencilBuffer: boolean;
  28088. /** @hidden */
  28089. _generateDepthBuffer: boolean;
  28090. /** @hidden */
  28091. _comparisonFunction: number;
  28092. /** @hidden */
  28093. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28094. /** @hidden */
  28095. _lodGenerationScale: number;
  28096. /** @hidden */
  28097. _lodGenerationOffset: number;
  28098. /** @hidden */
  28099. _colorTextureArray: Nullable<WebGLTexture>;
  28100. /** @hidden */
  28101. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28102. /** @hidden */
  28103. _lodTextureHigh: Nullable<BaseTexture>;
  28104. /** @hidden */
  28105. _lodTextureMid: Nullable<BaseTexture>;
  28106. /** @hidden */
  28107. _lodTextureLow: Nullable<BaseTexture>;
  28108. /** @hidden */
  28109. _isRGBD: boolean;
  28110. /** @hidden */
  28111. _linearSpecularLOD: boolean;
  28112. /** @hidden */
  28113. _irradianceTexture: Nullable<BaseTexture>;
  28114. /** @hidden */
  28115. _webGLTexture: Nullable<WebGLTexture>;
  28116. /** @hidden */
  28117. _references: number;
  28118. private _engine;
  28119. /**
  28120. * Gets the Engine the texture belongs to.
  28121. * @returns The babylon engine
  28122. */
  28123. getEngine(): Engine;
  28124. /**
  28125. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28126. */
  28127. readonly dataSource: number;
  28128. /**
  28129. * Creates a new InternalTexture
  28130. * @param engine defines the engine to use
  28131. * @param dataSource defines the type of data that will be used
  28132. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28133. */
  28134. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28135. /**
  28136. * Increments the number of references (ie. the number of Texture that point to it)
  28137. */
  28138. incrementReferences(): void;
  28139. /**
  28140. * Change the size of the texture (not the size of the content)
  28141. * @param width defines the new width
  28142. * @param height defines the new height
  28143. * @param depth defines the new depth (1 by default)
  28144. */
  28145. updateSize(width: int, height: int, depth?: int): void;
  28146. /** @hidden */
  28147. _rebuild(): void;
  28148. /** @hidden */
  28149. _swapAndDie(target: InternalTexture): void;
  28150. /**
  28151. * Dispose the current allocated resources
  28152. */
  28153. dispose(): void;
  28154. }
  28155. }
  28156. declare module BABYLON {
  28157. /**
  28158. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28159. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28160. */
  28161. export class EffectFallbacks {
  28162. private _defines;
  28163. private _currentRank;
  28164. private _maxRank;
  28165. private _mesh;
  28166. /**
  28167. * Removes the fallback from the bound mesh.
  28168. */
  28169. unBindMesh(): void;
  28170. /**
  28171. * Adds a fallback on the specified property.
  28172. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28173. * @param define The name of the define in the shader
  28174. */
  28175. addFallback(rank: number, define: string): void;
  28176. /**
  28177. * Sets the mesh to use CPU skinning when needing to fallback.
  28178. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28179. * @param mesh The mesh to use the fallbacks.
  28180. */
  28181. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28182. /**
  28183. * Checks to see if more fallbacks are still availible.
  28184. */
  28185. readonly hasMoreFallbacks: boolean;
  28186. /**
  28187. * Removes the defines that should be removed when falling back.
  28188. * @param currentDefines defines the current define statements for the shader.
  28189. * @param effect defines the current effect we try to compile
  28190. * @returns The resulting defines with defines of the current rank removed.
  28191. */
  28192. reduce(currentDefines: string, effect: Effect): string;
  28193. }
  28194. /**
  28195. * Options to be used when creating an effect.
  28196. */
  28197. export class EffectCreationOptions {
  28198. /**
  28199. * Atrributes that will be used in the shader.
  28200. */
  28201. attributes: string[];
  28202. /**
  28203. * Uniform varible names that will be set in the shader.
  28204. */
  28205. uniformsNames: string[];
  28206. /**
  28207. * Uniform buffer varible names that will be set in the shader.
  28208. */
  28209. uniformBuffersNames: string[];
  28210. /**
  28211. * Sampler texture variable names that will be set in the shader.
  28212. */
  28213. samplers: string[];
  28214. /**
  28215. * Define statements that will be set in the shader.
  28216. */
  28217. defines: any;
  28218. /**
  28219. * Possible fallbacks for this effect to improve performance when needed.
  28220. */
  28221. fallbacks: Nullable<EffectFallbacks>;
  28222. /**
  28223. * Callback that will be called when the shader is compiled.
  28224. */
  28225. onCompiled: Nullable<(effect: Effect) => void>;
  28226. /**
  28227. * Callback that will be called if an error occurs during shader compilation.
  28228. */
  28229. onError: Nullable<(effect: Effect, errors: string) => void>;
  28230. /**
  28231. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28232. */
  28233. indexParameters: any;
  28234. /**
  28235. * Max number of lights that can be used in the shader.
  28236. */
  28237. maxSimultaneousLights: number;
  28238. /**
  28239. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28240. */
  28241. transformFeedbackVaryings: Nullable<string[]>;
  28242. }
  28243. /**
  28244. * Effect containing vertex and fragment shader that can be executed on an object.
  28245. */
  28246. export class Effect implements IDisposable {
  28247. /**
  28248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28249. */
  28250. static ShadersRepository: string;
  28251. /**
  28252. * Name of the effect.
  28253. */
  28254. name: any;
  28255. /**
  28256. * String container all the define statements that should be set on the shader.
  28257. */
  28258. defines: string;
  28259. /**
  28260. * Callback that will be called when the shader is compiled.
  28261. */
  28262. onCompiled: Nullable<(effect: Effect) => void>;
  28263. /**
  28264. * Callback that will be called if an error occurs during shader compilation.
  28265. */
  28266. onError: Nullable<(effect: Effect, errors: string) => void>;
  28267. /**
  28268. * Callback that will be called when effect is bound.
  28269. */
  28270. onBind: Nullable<(effect: Effect) => void>;
  28271. /**
  28272. * Unique ID of the effect.
  28273. */
  28274. uniqueId: number;
  28275. /**
  28276. * Observable that will be called when the shader is compiled.
  28277. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28278. */
  28279. onCompileObservable: Observable<Effect>;
  28280. /**
  28281. * Observable that will be called if an error occurs during shader compilation.
  28282. */
  28283. onErrorObservable: Observable<Effect>;
  28284. /** @hidden */
  28285. _onBindObservable: Nullable<Observable<Effect>>;
  28286. /**
  28287. * Observable that will be called when effect is bound.
  28288. */
  28289. readonly onBindObservable: Observable<Effect>;
  28290. /** @hidden */
  28291. _bonesComputationForcedToCPU: boolean;
  28292. private static _uniqueIdSeed;
  28293. private _engine;
  28294. private _uniformBuffersNames;
  28295. private _uniformsNames;
  28296. private _samplerList;
  28297. private _samplers;
  28298. private _isReady;
  28299. private _compilationError;
  28300. private _attributesNames;
  28301. private _attributes;
  28302. private _uniforms;
  28303. /**
  28304. * Key for the effect.
  28305. * @hidden
  28306. */
  28307. _key: string;
  28308. private _indexParameters;
  28309. private _fallbacks;
  28310. private _vertexSourceCode;
  28311. private _fragmentSourceCode;
  28312. private _vertexSourceCodeOverride;
  28313. private _fragmentSourceCodeOverride;
  28314. private _transformFeedbackVaryings;
  28315. /**
  28316. * Compiled shader to webGL program.
  28317. * @hidden
  28318. */
  28319. _pipelineContext: Nullable<IPipelineContext>;
  28320. private _valueCache;
  28321. private static _baseCache;
  28322. /**
  28323. * Instantiates an effect.
  28324. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28325. * @param baseName Name of the effect.
  28326. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28327. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28328. * @param samplers List of sampler variables that will be passed to the shader.
  28329. * @param engine Engine to be used to render the effect
  28330. * @param defines Define statements to be added to the shader.
  28331. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28332. * @param onCompiled Callback that will be called when the shader is compiled.
  28333. * @param onError Callback that will be called if an error occurs during shader compilation.
  28334. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28335. */
  28336. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28337. private _useFinalCode;
  28338. /**
  28339. * Unique key for this effect
  28340. */
  28341. readonly key: string;
  28342. /**
  28343. * If the effect has been compiled and prepared.
  28344. * @returns if the effect is compiled and prepared.
  28345. */
  28346. isReady(): boolean;
  28347. private _isReadyInternal;
  28348. /**
  28349. * The engine the effect was initialized with.
  28350. * @returns the engine.
  28351. */
  28352. getEngine(): Engine;
  28353. /**
  28354. * The pipeline context for this effect
  28355. * @returns the associated pipeline context
  28356. */
  28357. getPipelineContext(): Nullable<IPipelineContext>;
  28358. /**
  28359. * The set of names of attribute variables for the shader.
  28360. * @returns An array of attribute names.
  28361. */
  28362. getAttributesNames(): string[];
  28363. /**
  28364. * Returns the attribute at the given index.
  28365. * @param index The index of the attribute.
  28366. * @returns The location of the attribute.
  28367. */
  28368. getAttributeLocation(index: number): number;
  28369. /**
  28370. * Returns the attribute based on the name of the variable.
  28371. * @param name of the attribute to look up.
  28372. * @returns the attribute location.
  28373. */
  28374. getAttributeLocationByName(name: string): number;
  28375. /**
  28376. * The number of attributes.
  28377. * @returns the numnber of attributes.
  28378. */
  28379. getAttributesCount(): number;
  28380. /**
  28381. * Gets the index of a uniform variable.
  28382. * @param uniformName of the uniform to look up.
  28383. * @returns the index.
  28384. */
  28385. getUniformIndex(uniformName: string): number;
  28386. /**
  28387. * Returns the attribute based on the name of the variable.
  28388. * @param uniformName of the uniform to look up.
  28389. * @returns the location of the uniform.
  28390. */
  28391. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28392. /**
  28393. * Returns an array of sampler variable names
  28394. * @returns The array of sampler variable neames.
  28395. */
  28396. getSamplers(): string[];
  28397. /**
  28398. * The error from the last compilation.
  28399. * @returns the error string.
  28400. */
  28401. getCompilationError(): string;
  28402. /**
  28403. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28404. * @param func The callback to be used.
  28405. */
  28406. executeWhenCompiled(func: (effect: Effect) => void): void;
  28407. private _checkIsReady;
  28408. /** @hidden */
  28409. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28410. /** @hidden */
  28411. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28412. /** @hidden */
  28413. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28414. /**
  28415. * Recompiles the webGL program
  28416. * @param vertexSourceCode The source code for the vertex shader.
  28417. * @param fragmentSourceCode The source code for the fragment shader.
  28418. * @param onCompiled Callback called when completed.
  28419. * @param onError Callback called on error.
  28420. * @hidden
  28421. */
  28422. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28423. /**
  28424. * Prepares the effect
  28425. * @hidden
  28426. */
  28427. _prepareEffect(): void;
  28428. private _processCompilationErrors;
  28429. /**
  28430. * Checks if the effect is supported. (Must be called after compilation)
  28431. */
  28432. readonly isSupported: boolean;
  28433. /**
  28434. * Binds a texture to the engine to be used as output of the shader.
  28435. * @param channel Name of the output variable.
  28436. * @param texture Texture to bind.
  28437. * @hidden
  28438. */
  28439. _bindTexture(channel: string, texture: InternalTexture): void;
  28440. /**
  28441. * Sets a texture on the engine to be used in the shader.
  28442. * @param channel Name of the sampler variable.
  28443. * @param texture Texture to set.
  28444. */
  28445. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28446. /**
  28447. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28448. * @param channel Name of the sampler variable.
  28449. * @param texture Texture to set.
  28450. */
  28451. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28452. /**
  28453. * Sets an array of textures on the engine to be used in the shader.
  28454. * @param channel Name of the variable.
  28455. * @param textures Textures to set.
  28456. */
  28457. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28458. /**
  28459. * 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)
  28460. * @param channel Name of the sampler variable.
  28461. * @param postProcess Post process to get the input texture from.
  28462. */
  28463. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28464. /**
  28465. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28466. * 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)
  28467. * @param channel Name of the sampler variable.
  28468. * @param postProcess Post process to get the output texture from.
  28469. */
  28470. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28471. /** @hidden */
  28472. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28473. /** @hidden */
  28474. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28475. /** @hidden */
  28476. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28477. /** @hidden */
  28478. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28479. /**
  28480. * Binds a buffer to a uniform.
  28481. * @param buffer Buffer to bind.
  28482. * @param name Name of the uniform variable to bind to.
  28483. */
  28484. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28485. /**
  28486. * Binds block to a uniform.
  28487. * @param blockName Name of the block to bind.
  28488. * @param index Index to bind.
  28489. */
  28490. bindUniformBlock(blockName: string, index: number): void;
  28491. /**
  28492. * Sets an interger value on a uniform variable.
  28493. * @param uniformName Name of the variable.
  28494. * @param value Value to be set.
  28495. * @returns this effect.
  28496. */
  28497. setInt(uniformName: string, value: number): Effect;
  28498. /**
  28499. * Sets an int array on a uniform variable.
  28500. * @param uniformName Name of the variable.
  28501. * @param array array to be set.
  28502. * @returns this effect.
  28503. */
  28504. setIntArray(uniformName: string, array: Int32Array): Effect;
  28505. /**
  28506. * 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)
  28507. * @param uniformName Name of the variable.
  28508. * @param array array to be set.
  28509. * @returns this effect.
  28510. */
  28511. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28512. /**
  28513. * 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)
  28514. * @param uniformName Name of the variable.
  28515. * @param array array to be set.
  28516. * @returns this effect.
  28517. */
  28518. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28519. /**
  28520. * 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)
  28521. * @param uniformName Name of the variable.
  28522. * @param array array to be set.
  28523. * @returns this effect.
  28524. */
  28525. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28526. /**
  28527. * Sets an float array on a uniform variable.
  28528. * @param uniformName Name of the variable.
  28529. * @param array array to be set.
  28530. * @returns this effect.
  28531. */
  28532. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28533. /**
  28534. * 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)
  28535. * @param uniformName Name of the variable.
  28536. * @param array array to be set.
  28537. * @returns this effect.
  28538. */
  28539. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28540. /**
  28541. * 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)
  28542. * @param uniformName Name of the variable.
  28543. * @param array array to be set.
  28544. * @returns this effect.
  28545. */
  28546. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28547. /**
  28548. * 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)
  28549. * @param uniformName Name of the variable.
  28550. * @param array array to be set.
  28551. * @returns this effect.
  28552. */
  28553. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28554. /**
  28555. * Sets an array on a uniform variable.
  28556. * @param uniformName Name of the variable.
  28557. * @param array array to be set.
  28558. * @returns this effect.
  28559. */
  28560. setArray(uniformName: string, array: number[]): Effect;
  28561. /**
  28562. * 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)
  28563. * @param uniformName Name of the variable.
  28564. * @param array array to be set.
  28565. * @returns this effect.
  28566. */
  28567. setArray2(uniformName: string, array: number[]): Effect;
  28568. /**
  28569. * 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)
  28570. * @param uniformName Name of the variable.
  28571. * @param array array to be set.
  28572. * @returns this effect.
  28573. */
  28574. setArray3(uniformName: string, array: number[]): Effect;
  28575. /**
  28576. * 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)
  28577. * @param uniformName Name of the variable.
  28578. * @param array array to be set.
  28579. * @returns this effect.
  28580. */
  28581. setArray4(uniformName: string, array: number[]): Effect;
  28582. /**
  28583. * Sets matrices on a uniform variable.
  28584. * @param uniformName Name of the variable.
  28585. * @param matrices matrices to be set.
  28586. * @returns this effect.
  28587. */
  28588. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28589. /**
  28590. * Sets matrix on a uniform variable.
  28591. * @param uniformName Name of the variable.
  28592. * @param matrix matrix to be set.
  28593. * @returns this effect.
  28594. */
  28595. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28596. /**
  28597. * 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)
  28598. * @param uniformName Name of the variable.
  28599. * @param matrix matrix to be set.
  28600. * @returns this effect.
  28601. */
  28602. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28603. /**
  28604. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28605. * @param uniformName Name of the variable.
  28606. * @param matrix matrix to be set.
  28607. * @returns this effect.
  28608. */
  28609. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28610. /**
  28611. * Sets a float on a uniform variable.
  28612. * @param uniformName Name of the variable.
  28613. * @param value value to be set.
  28614. * @returns this effect.
  28615. */
  28616. setFloat(uniformName: string, value: number): Effect;
  28617. /**
  28618. * Sets a boolean on a uniform variable.
  28619. * @param uniformName Name of the variable.
  28620. * @param bool value to be set.
  28621. * @returns this effect.
  28622. */
  28623. setBool(uniformName: string, bool: boolean): Effect;
  28624. /**
  28625. * Sets a Vector2 on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param vector2 vector2 to be set.
  28628. * @returns this effect.
  28629. */
  28630. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28631. /**
  28632. * Sets a float2 on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param x First float in float2.
  28635. * @param y Second float in float2.
  28636. * @returns this effect.
  28637. */
  28638. setFloat2(uniformName: string, x: number, y: number): Effect;
  28639. /**
  28640. * Sets a Vector3 on a uniform variable.
  28641. * @param uniformName Name of the variable.
  28642. * @param vector3 Value to be set.
  28643. * @returns this effect.
  28644. */
  28645. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28646. /**
  28647. * Sets a float3 on a uniform variable.
  28648. * @param uniformName Name of the variable.
  28649. * @param x First float in float3.
  28650. * @param y Second float in float3.
  28651. * @param z Third float in float3.
  28652. * @returns this effect.
  28653. */
  28654. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28655. /**
  28656. * Sets a Vector4 on a uniform variable.
  28657. * @param uniformName Name of the variable.
  28658. * @param vector4 Value to be set.
  28659. * @returns this effect.
  28660. */
  28661. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28662. /**
  28663. * Sets a float4 on a uniform variable.
  28664. * @param uniformName Name of the variable.
  28665. * @param x First float in float4.
  28666. * @param y Second float in float4.
  28667. * @param z Third float in float4.
  28668. * @param w Fourth float in float4.
  28669. * @returns this effect.
  28670. */
  28671. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28672. /**
  28673. * Sets a Color3 on a uniform variable.
  28674. * @param uniformName Name of the variable.
  28675. * @param color3 Value to be set.
  28676. * @returns this effect.
  28677. */
  28678. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28679. /**
  28680. * Sets a Color4 on a uniform variable.
  28681. * @param uniformName Name of the variable.
  28682. * @param color3 Value to be set.
  28683. * @param alpha Alpha value to be set.
  28684. * @returns this effect.
  28685. */
  28686. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28687. /**
  28688. * Sets a Color4 on a uniform variable
  28689. * @param uniformName defines the name of the variable
  28690. * @param color4 defines the value to be set
  28691. * @returns this effect.
  28692. */
  28693. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28694. /** Release all associated resources */
  28695. dispose(): void;
  28696. /**
  28697. * This function will add a new shader to the shader store
  28698. * @param name the name of the shader
  28699. * @param pixelShader optional pixel shader content
  28700. * @param vertexShader optional vertex shader content
  28701. */
  28702. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28703. /**
  28704. * Store of each shader (The can be looked up using effect.key)
  28705. */
  28706. static ShadersStore: {
  28707. [key: string]: string;
  28708. };
  28709. /**
  28710. * Store of each included file for a shader (The can be looked up using effect.key)
  28711. */
  28712. static IncludesShadersStore: {
  28713. [key: string]: string;
  28714. };
  28715. /**
  28716. * Resets the cache of effects.
  28717. */
  28718. static ResetCache(): void;
  28719. }
  28720. }
  28721. declare module BABYLON {
  28722. /**
  28723. * Uniform buffer objects.
  28724. *
  28725. * Handles blocks of uniform on the GPU.
  28726. *
  28727. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28728. *
  28729. * For more information, please refer to :
  28730. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28731. */
  28732. export class UniformBuffer {
  28733. private _engine;
  28734. private _buffer;
  28735. private _data;
  28736. private _bufferData;
  28737. private _dynamic?;
  28738. private _uniformLocations;
  28739. private _uniformSizes;
  28740. private _uniformLocationPointer;
  28741. private _needSync;
  28742. private _noUBO;
  28743. private _currentEffect;
  28744. private static _MAX_UNIFORM_SIZE;
  28745. private static _tempBuffer;
  28746. /**
  28747. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28748. * This is dynamic to allow compat with webgl 1 and 2.
  28749. * You will need to pass the name of the uniform as well as the value.
  28750. */
  28751. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28752. /**
  28753. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28754. * This is dynamic to allow compat with webgl 1 and 2.
  28755. * You will need to pass the name of the uniform as well as the value.
  28756. */
  28757. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28758. /**
  28759. * Lambda to Update a single float in a uniform buffer.
  28760. * This is dynamic to allow compat with webgl 1 and 2.
  28761. * You will need to pass the name of the uniform as well as the value.
  28762. */
  28763. updateFloat: (name: string, x: number) => void;
  28764. /**
  28765. * Lambda to Update a vec2 of float in a uniform buffer.
  28766. * This is dynamic to allow compat with webgl 1 and 2.
  28767. * You will need to pass the name of the uniform as well as the value.
  28768. */
  28769. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28770. /**
  28771. * Lambda to Update a vec3 of float in a uniform buffer.
  28772. * This is dynamic to allow compat with webgl 1 and 2.
  28773. * You will need to pass the name of the uniform as well as the value.
  28774. */
  28775. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28776. /**
  28777. * Lambda to Update a vec4 of float in a uniform buffer.
  28778. * This is dynamic to allow compat with webgl 1 and 2.
  28779. * You will need to pass the name of the uniform as well as the value.
  28780. */
  28781. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28782. /**
  28783. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28784. * This is dynamic to allow compat with webgl 1 and 2.
  28785. * You will need to pass the name of the uniform as well as the value.
  28786. */
  28787. updateMatrix: (name: string, mat: Matrix) => void;
  28788. /**
  28789. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28790. * This is dynamic to allow compat with webgl 1 and 2.
  28791. * You will need to pass the name of the uniform as well as the value.
  28792. */
  28793. updateVector3: (name: string, vector: Vector3) => void;
  28794. /**
  28795. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28796. * This is dynamic to allow compat with webgl 1 and 2.
  28797. * You will need to pass the name of the uniform as well as the value.
  28798. */
  28799. updateVector4: (name: string, vector: Vector4) => void;
  28800. /**
  28801. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28802. * This is dynamic to allow compat with webgl 1 and 2.
  28803. * You will need to pass the name of the uniform as well as the value.
  28804. */
  28805. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28806. /**
  28807. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28808. * This is dynamic to allow compat with webgl 1 and 2.
  28809. * You will need to pass the name of the uniform as well as the value.
  28810. */
  28811. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28812. /**
  28813. * Instantiates a new Uniform buffer objects.
  28814. *
  28815. * Handles blocks of uniform on the GPU.
  28816. *
  28817. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28818. *
  28819. * For more information, please refer to :
  28820. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28821. * @param engine Define the engine the buffer is associated with
  28822. * @param data Define the data contained in the buffer
  28823. * @param dynamic Define if the buffer is updatable
  28824. */
  28825. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28826. /**
  28827. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28828. * or just falling back on setUniformXXX calls.
  28829. */
  28830. readonly useUbo: boolean;
  28831. /**
  28832. * Indicates if the WebGL underlying uniform buffer is in sync
  28833. * with the javascript cache data.
  28834. */
  28835. readonly isSync: boolean;
  28836. /**
  28837. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28838. * Also, a dynamic UniformBuffer will disable cache verification and always
  28839. * update the underlying WebGL uniform buffer to the GPU.
  28840. * @returns if Dynamic, otherwise false
  28841. */
  28842. isDynamic(): boolean;
  28843. /**
  28844. * The data cache on JS side.
  28845. * @returns the underlying data as a float array
  28846. */
  28847. getData(): Float32Array;
  28848. /**
  28849. * The underlying WebGL Uniform buffer.
  28850. * @returns the webgl buffer
  28851. */
  28852. getBuffer(): Nullable<DataBuffer>;
  28853. /**
  28854. * std140 layout specifies how to align data within an UBO structure.
  28855. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28856. * for specs.
  28857. */
  28858. private _fillAlignment;
  28859. /**
  28860. * Adds an uniform in the buffer.
  28861. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28862. * for the layout to be correct !
  28863. * @param name Name of the uniform, as used in the uniform block in the shader.
  28864. * @param size Data size, or data directly.
  28865. */
  28866. addUniform(name: string, size: number | number[]): void;
  28867. /**
  28868. * Adds a Matrix 4x4 to the uniform buffer.
  28869. * @param name Name of the uniform, as used in the uniform block in the shader.
  28870. * @param mat A 4x4 matrix.
  28871. */
  28872. addMatrix(name: string, mat: Matrix): void;
  28873. /**
  28874. * Adds a vec2 to the uniform buffer.
  28875. * @param name Name of the uniform, as used in the uniform block in the shader.
  28876. * @param x Define the x component value of the vec2
  28877. * @param y Define the y component value of the vec2
  28878. */
  28879. addFloat2(name: string, x: number, y: number): void;
  28880. /**
  28881. * Adds a vec3 to the uniform buffer.
  28882. * @param name Name of the uniform, as used in the uniform block in the shader.
  28883. * @param x Define the x component value of the vec3
  28884. * @param y Define the y component value of the vec3
  28885. * @param z Define the z component value of the vec3
  28886. */
  28887. addFloat3(name: string, x: number, y: number, z: number): void;
  28888. /**
  28889. * Adds a vec3 to the uniform buffer.
  28890. * @param name Name of the uniform, as used in the uniform block in the shader.
  28891. * @param color Define the vec3 from a Color
  28892. */
  28893. addColor3(name: string, color: Color3): void;
  28894. /**
  28895. * Adds a vec4 to the uniform buffer.
  28896. * @param name Name of the uniform, as used in the uniform block in the shader.
  28897. * @param color Define the rgb components from a Color
  28898. * @param alpha Define the a component of the vec4
  28899. */
  28900. addColor4(name: string, color: Color3, alpha: number): void;
  28901. /**
  28902. * Adds a vec3 to the uniform buffer.
  28903. * @param name Name of the uniform, as used in the uniform block in the shader.
  28904. * @param vector Define the vec3 components from a Vector
  28905. */
  28906. addVector3(name: string, vector: Vector3): void;
  28907. /**
  28908. * Adds a Matrix 3x3 to the uniform buffer.
  28909. * @param name Name of the uniform, as used in the uniform block in the shader.
  28910. */
  28911. addMatrix3x3(name: string): void;
  28912. /**
  28913. * Adds a Matrix 2x2 to the uniform buffer.
  28914. * @param name Name of the uniform, as used in the uniform block in the shader.
  28915. */
  28916. addMatrix2x2(name: string): void;
  28917. /**
  28918. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28919. */
  28920. create(): void;
  28921. /** @hidden */
  28922. _rebuild(): void;
  28923. /**
  28924. * Updates the WebGL Uniform Buffer on the GPU.
  28925. * If the `dynamic` flag is set to true, no cache comparison is done.
  28926. * Otherwise, the buffer will be updated only if the cache differs.
  28927. */
  28928. update(): void;
  28929. /**
  28930. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28931. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28932. * @param data Define the flattened data
  28933. * @param size Define the size of the data.
  28934. */
  28935. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28936. private _valueCache;
  28937. private _cacheMatrix;
  28938. private _updateMatrix3x3ForUniform;
  28939. private _updateMatrix3x3ForEffect;
  28940. private _updateMatrix2x2ForEffect;
  28941. private _updateMatrix2x2ForUniform;
  28942. private _updateFloatForEffect;
  28943. private _updateFloatForUniform;
  28944. private _updateFloat2ForEffect;
  28945. private _updateFloat2ForUniform;
  28946. private _updateFloat3ForEffect;
  28947. private _updateFloat3ForUniform;
  28948. private _updateFloat4ForEffect;
  28949. private _updateFloat4ForUniform;
  28950. private _updateMatrixForEffect;
  28951. private _updateMatrixForUniform;
  28952. private _updateVector3ForEffect;
  28953. private _updateVector3ForUniform;
  28954. private _updateVector4ForEffect;
  28955. private _updateVector4ForUniform;
  28956. private _updateColor3ForEffect;
  28957. private _updateColor3ForUniform;
  28958. private _updateColor4ForEffect;
  28959. private _updateColor4ForUniform;
  28960. /**
  28961. * Sets a sampler uniform on the effect.
  28962. * @param name Define the name of the sampler.
  28963. * @param texture Define the texture to set in the sampler
  28964. */
  28965. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28966. /**
  28967. * Directly updates the value of the uniform in the cache AND on the GPU.
  28968. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28969. * @param data Define the flattened data
  28970. */
  28971. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28972. /**
  28973. * Binds this uniform buffer to an effect.
  28974. * @param effect Define the effect to bind the buffer to
  28975. * @param name Name of the uniform block in the shader.
  28976. */
  28977. bindToEffect(effect: Effect, name: string): void;
  28978. /**
  28979. * Disposes the uniform buffer.
  28980. */
  28981. dispose(): void;
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. /**
  28986. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28988. */
  28989. export class Analyser {
  28990. /**
  28991. * Gets or sets the smoothing
  28992. * @ignorenaming
  28993. */
  28994. SMOOTHING: number;
  28995. /**
  28996. * Gets or sets the FFT table size
  28997. * @ignorenaming
  28998. */
  28999. FFT_SIZE: number;
  29000. /**
  29001. * Gets or sets the bar graph amplitude
  29002. * @ignorenaming
  29003. */
  29004. BARGRAPHAMPLITUDE: number;
  29005. /**
  29006. * Gets or sets the position of the debug canvas
  29007. * @ignorenaming
  29008. */
  29009. DEBUGCANVASPOS: {
  29010. x: number;
  29011. y: number;
  29012. };
  29013. /**
  29014. * Gets or sets the debug canvas size
  29015. * @ignorenaming
  29016. */
  29017. DEBUGCANVASSIZE: {
  29018. width: number;
  29019. height: number;
  29020. };
  29021. private _byteFreqs;
  29022. private _byteTime;
  29023. private _floatFreqs;
  29024. private _webAudioAnalyser;
  29025. private _debugCanvas;
  29026. private _debugCanvasContext;
  29027. private _scene;
  29028. private _registerFunc;
  29029. private _audioEngine;
  29030. /**
  29031. * Creates a new analyser
  29032. * @param scene defines hosting scene
  29033. */
  29034. constructor(scene: Scene);
  29035. /**
  29036. * Get the number of data values you will have to play with for the visualization
  29037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29038. * @returns a number
  29039. */
  29040. getFrequencyBinCount(): number;
  29041. /**
  29042. * Gets the current frequency data as a byte array
  29043. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29044. * @returns a Uint8Array
  29045. */
  29046. getByteFrequencyData(): Uint8Array;
  29047. /**
  29048. * Gets the current waveform as a byte array
  29049. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29050. * @returns a Uint8Array
  29051. */
  29052. getByteTimeDomainData(): Uint8Array;
  29053. /**
  29054. * Gets the current frequency data as a float array
  29055. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29056. * @returns a Float32Array
  29057. */
  29058. getFloatFrequencyData(): Float32Array;
  29059. /**
  29060. * Renders the debug canvas
  29061. */
  29062. drawDebugCanvas(): void;
  29063. /**
  29064. * Stops rendering the debug canvas and removes it
  29065. */
  29066. stopDebugCanvas(): void;
  29067. /**
  29068. * Connects two audio nodes
  29069. * @param inputAudioNode defines first node to connect
  29070. * @param outputAudioNode defines second node to connect
  29071. */
  29072. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29073. /**
  29074. * Releases all associated resources
  29075. */
  29076. dispose(): void;
  29077. }
  29078. }
  29079. declare module BABYLON {
  29080. /**
  29081. * This represents an audio engine and it is responsible
  29082. * to play, synchronize and analyse sounds throughout the application.
  29083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29084. */
  29085. export interface IAudioEngine extends IDisposable {
  29086. /**
  29087. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29088. */
  29089. readonly canUseWebAudio: boolean;
  29090. /**
  29091. * Gets the current AudioContext if available.
  29092. */
  29093. readonly audioContext: Nullable<AudioContext>;
  29094. /**
  29095. * The master gain node defines the global audio volume of your audio engine.
  29096. */
  29097. readonly masterGain: GainNode;
  29098. /**
  29099. * Gets whether or not mp3 are supported by your browser.
  29100. */
  29101. readonly isMP3supported: boolean;
  29102. /**
  29103. * Gets whether or not ogg are supported by your browser.
  29104. */
  29105. readonly isOGGsupported: boolean;
  29106. /**
  29107. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29108. * @ignoreNaming
  29109. */
  29110. WarnedWebAudioUnsupported: boolean;
  29111. /**
  29112. * Defines if the audio engine relies on a custom unlocked button.
  29113. * In this case, the embedded button will not be displayed.
  29114. */
  29115. useCustomUnlockedButton: boolean;
  29116. /**
  29117. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29118. */
  29119. readonly unlocked: boolean;
  29120. /**
  29121. * Event raised when audio has been unlocked on the browser.
  29122. */
  29123. onAudioUnlockedObservable: Observable<AudioEngine>;
  29124. /**
  29125. * Event raised when audio has been locked on the browser.
  29126. */
  29127. onAudioLockedObservable: Observable<AudioEngine>;
  29128. /**
  29129. * Flags the audio engine in Locked state.
  29130. * This happens due to new browser policies preventing audio to autoplay.
  29131. */
  29132. lock(): void;
  29133. /**
  29134. * Unlocks the audio engine once a user action has been done on the dom.
  29135. * This is helpful to resume play once browser policies have been satisfied.
  29136. */
  29137. unlock(): void;
  29138. }
  29139. /**
  29140. * This represents the default audio engine used in babylon.
  29141. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29143. */
  29144. export class AudioEngine implements IAudioEngine {
  29145. private _audioContext;
  29146. private _audioContextInitialized;
  29147. private _muteButton;
  29148. private _hostElement;
  29149. /**
  29150. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29151. */
  29152. canUseWebAudio: boolean;
  29153. /**
  29154. * The master gain node defines the global audio volume of your audio engine.
  29155. */
  29156. masterGain: GainNode;
  29157. /**
  29158. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29159. * @ignoreNaming
  29160. */
  29161. WarnedWebAudioUnsupported: boolean;
  29162. /**
  29163. * Gets whether or not mp3 are supported by your browser.
  29164. */
  29165. isMP3supported: boolean;
  29166. /**
  29167. * Gets whether or not ogg are supported by your browser.
  29168. */
  29169. isOGGsupported: boolean;
  29170. /**
  29171. * Gets whether audio has been unlocked on the device.
  29172. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29173. * a user interaction has happened.
  29174. */
  29175. unlocked: boolean;
  29176. /**
  29177. * Defines if the audio engine relies on a custom unlocked button.
  29178. * In this case, the embedded button will not be displayed.
  29179. */
  29180. useCustomUnlockedButton: boolean;
  29181. /**
  29182. * Event raised when audio has been unlocked on the browser.
  29183. */
  29184. onAudioUnlockedObservable: Observable<AudioEngine>;
  29185. /**
  29186. * Event raised when audio has been locked on the browser.
  29187. */
  29188. onAudioLockedObservable: Observable<AudioEngine>;
  29189. /**
  29190. * Gets the current AudioContext if available.
  29191. */
  29192. readonly audioContext: Nullable<AudioContext>;
  29193. private _connectedAnalyser;
  29194. /**
  29195. * Instantiates a new audio engine.
  29196. *
  29197. * There should be only one per page as some browsers restrict the number
  29198. * of audio contexts you can create.
  29199. * @param hostElement defines the host element where to display the mute icon if necessary
  29200. */
  29201. constructor(hostElement?: Nullable<HTMLElement>);
  29202. /**
  29203. * Flags the audio engine in Locked state.
  29204. * This happens due to new browser policies preventing audio to autoplay.
  29205. */
  29206. lock(): void;
  29207. /**
  29208. * Unlocks the audio engine once a user action has been done on the dom.
  29209. * This is helpful to resume play once browser policies have been satisfied.
  29210. */
  29211. unlock(): void;
  29212. private _resumeAudioContext;
  29213. private _initializeAudioContext;
  29214. private _tryToRun;
  29215. private _triggerRunningState;
  29216. private _triggerSuspendedState;
  29217. private _displayMuteButton;
  29218. private _moveButtonToTopLeft;
  29219. private _onResize;
  29220. private _hideMuteButton;
  29221. /**
  29222. * Destroy and release the resources associated with the audio ccontext.
  29223. */
  29224. dispose(): void;
  29225. /**
  29226. * Gets the global volume sets on the master gain.
  29227. * @returns the global volume if set or -1 otherwise
  29228. */
  29229. getGlobalVolume(): number;
  29230. /**
  29231. * Sets the global volume of your experience (sets on the master gain).
  29232. * @param newVolume Defines the new global volume of the application
  29233. */
  29234. setGlobalVolume(newVolume: number): void;
  29235. /**
  29236. * Connect the audio engine to an audio analyser allowing some amazing
  29237. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29239. * @param analyser The analyser to connect to the engine
  29240. */
  29241. connectToAnalyser(analyser: Analyser): void;
  29242. }
  29243. }
  29244. declare module BABYLON {
  29245. /**
  29246. * Interface used to present a loading screen while loading a scene
  29247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29248. */
  29249. export interface ILoadingScreen {
  29250. /**
  29251. * Function called to display the loading screen
  29252. */
  29253. displayLoadingUI: () => void;
  29254. /**
  29255. * Function called to hide the loading screen
  29256. */
  29257. hideLoadingUI: () => void;
  29258. /**
  29259. * Gets or sets the color to use for the background
  29260. */
  29261. loadingUIBackgroundColor: string;
  29262. /**
  29263. * Gets or sets the text to display while loading
  29264. */
  29265. loadingUIText: string;
  29266. }
  29267. /**
  29268. * Class used for the default loading screen
  29269. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29270. */
  29271. export class DefaultLoadingScreen implements ILoadingScreen {
  29272. private _renderingCanvas;
  29273. private _loadingText;
  29274. private _loadingDivBackgroundColor;
  29275. private _loadingDiv;
  29276. private _loadingTextDiv;
  29277. /** Gets or sets the logo url to use for the default loading screen */
  29278. static DefaultLogoUrl: string;
  29279. /** Gets or sets the spinner url to use for the default loading screen */
  29280. static DefaultSpinnerUrl: string;
  29281. /**
  29282. * Creates a new default loading screen
  29283. * @param _renderingCanvas defines the canvas used to render the scene
  29284. * @param _loadingText defines the default text to display
  29285. * @param _loadingDivBackgroundColor defines the default background color
  29286. */
  29287. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29288. /**
  29289. * Function called to display the loading screen
  29290. */
  29291. displayLoadingUI(): void;
  29292. /**
  29293. * Function called to hide the loading screen
  29294. */
  29295. hideLoadingUI(): void;
  29296. /**
  29297. * Gets or sets the text to display while loading
  29298. */
  29299. loadingUIText: string;
  29300. /**
  29301. * Gets or sets the color to use for the background
  29302. */
  29303. loadingUIBackgroundColor: string;
  29304. private _resizeLoadingUI;
  29305. }
  29306. }
  29307. declare module BABYLON {
  29308. /** @hidden */
  29309. export class WebGLPipelineContext implements IPipelineContext {
  29310. engine: Engine;
  29311. program: Nullable<WebGLProgram>;
  29312. context?: WebGLRenderingContext;
  29313. vertexShader?: WebGLShader;
  29314. fragmentShader?: WebGLShader;
  29315. isParallelCompiled: boolean;
  29316. onCompiled?: () => void;
  29317. transformFeedback?: WebGLTransformFeedback | null;
  29318. readonly isAsync: boolean;
  29319. readonly isReady: boolean;
  29320. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29321. }
  29322. }
  29323. declare module BABYLON {
  29324. /** @hidden */
  29325. export class WebGLDataBuffer extends DataBuffer {
  29326. private _buffer;
  29327. constructor(resource: WebGLBuffer);
  29328. readonly underlyingResource: any;
  29329. }
  29330. }
  29331. declare module BABYLON {
  29332. /** @hidden */
  29333. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29334. attributeProcessor(attribute: string): string;
  29335. varyingProcessor(varying: string, isFragment: boolean): string;
  29336. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29337. }
  29338. }
  29339. declare module BABYLON {
  29340. /**
  29341. * This class is used to track a performance counter which is number based.
  29342. * The user has access to many properties which give statistics of different nature.
  29343. *
  29344. * The implementer can track two kinds of Performance Counter: time and count.
  29345. * 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.
  29346. * 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.
  29347. */
  29348. export class PerfCounter {
  29349. /**
  29350. * Gets or sets a global boolean to turn on and off all the counters
  29351. */
  29352. static Enabled: boolean;
  29353. /**
  29354. * Returns the smallest value ever
  29355. */
  29356. readonly min: number;
  29357. /**
  29358. * Returns the biggest value ever
  29359. */
  29360. readonly max: number;
  29361. /**
  29362. * Returns the average value since the performance counter is running
  29363. */
  29364. readonly average: number;
  29365. /**
  29366. * Returns the average value of the last second the counter was monitored
  29367. */
  29368. readonly lastSecAverage: number;
  29369. /**
  29370. * Returns the current value
  29371. */
  29372. readonly current: number;
  29373. /**
  29374. * Gets the accumulated total
  29375. */
  29376. readonly total: number;
  29377. /**
  29378. * Gets the total value count
  29379. */
  29380. readonly count: number;
  29381. /**
  29382. * Creates a new counter
  29383. */
  29384. constructor();
  29385. /**
  29386. * Call this method to start monitoring a new frame.
  29387. * 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.
  29388. */
  29389. fetchNewFrame(): void;
  29390. /**
  29391. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29392. * @param newCount the count value to add to the monitored count
  29393. * @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.
  29394. */
  29395. addCount(newCount: number, fetchResult: boolean): void;
  29396. /**
  29397. * Start monitoring this performance counter
  29398. */
  29399. beginMonitoring(): void;
  29400. /**
  29401. * Compute the time lapsed since the previous beginMonitoring() call.
  29402. * @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
  29403. */
  29404. endMonitoring(newFrame?: boolean): void;
  29405. private _fetchResult;
  29406. private _startMonitoringTime;
  29407. private _min;
  29408. private _max;
  29409. private _average;
  29410. private _current;
  29411. private _totalValueCount;
  29412. private _totalAccumulated;
  29413. private _lastSecAverage;
  29414. private _lastSecAccumulated;
  29415. private _lastSecTime;
  29416. private _lastSecValueCount;
  29417. }
  29418. }
  29419. declare module BABYLON {
  29420. /**
  29421. * Interface for any object that can request an animation frame
  29422. */
  29423. export interface ICustomAnimationFrameRequester {
  29424. /**
  29425. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29426. */
  29427. renderFunction?: Function;
  29428. /**
  29429. * Called to request the next frame to render to
  29430. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29431. */
  29432. requestAnimationFrame: Function;
  29433. /**
  29434. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29435. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29436. */
  29437. requestID?: number;
  29438. }
  29439. }
  29440. declare module BABYLON {
  29441. /**
  29442. * Settings for finer control over video usage
  29443. */
  29444. export interface VideoTextureSettings {
  29445. /**
  29446. * Applies `autoplay` to video, if specified
  29447. */
  29448. autoPlay?: boolean;
  29449. /**
  29450. * Applies `loop` to video, if specified
  29451. */
  29452. loop?: boolean;
  29453. /**
  29454. * Automatically updates internal texture from video at every frame in the render loop
  29455. */
  29456. autoUpdateTexture: boolean;
  29457. /**
  29458. * Image src displayed during the video loading or until the user interacts with the video.
  29459. */
  29460. poster?: string;
  29461. }
  29462. /**
  29463. * If you want to display a video in your scene, this is the special texture for that.
  29464. * This special texture works similar to other textures, with the exception of a few parameters.
  29465. * @see https://doc.babylonjs.com/how_to/video_texture
  29466. */
  29467. export class VideoTexture extends Texture {
  29468. /**
  29469. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29470. */
  29471. readonly autoUpdateTexture: boolean;
  29472. /**
  29473. * The video instance used by the texture internally
  29474. */
  29475. readonly video: HTMLVideoElement;
  29476. private _onUserActionRequestedObservable;
  29477. /**
  29478. * Event triggerd when a dom action is required by the user to play the video.
  29479. * This happens due to recent changes in browser policies preventing video to auto start.
  29480. */
  29481. readonly onUserActionRequestedObservable: Observable<Texture>;
  29482. private _generateMipMaps;
  29483. private _engine;
  29484. private _stillImageCaptured;
  29485. private _displayingPosterTexture;
  29486. private _settings;
  29487. private _createInternalTextureOnEvent;
  29488. /**
  29489. * Creates a video texture.
  29490. * If you want to display a video in your scene, this is the special texture for that.
  29491. * This special texture works similar to other textures, with the exception of a few parameters.
  29492. * @see https://doc.babylonjs.com/how_to/video_texture
  29493. * @param name optional name, will detect from video source, if not defined
  29494. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29495. * @param scene is obviously the current scene.
  29496. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29497. * @param invertY is false by default but can be used to invert video on Y axis
  29498. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29499. * @param settings allows finer control over video usage
  29500. */
  29501. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29502. private _getName;
  29503. private _getVideo;
  29504. private _createInternalTexture;
  29505. private reset;
  29506. /**
  29507. * @hidden Internal method to initiate `update`.
  29508. */
  29509. _rebuild(): void;
  29510. /**
  29511. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29512. */
  29513. update(): void;
  29514. /**
  29515. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29516. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29517. */
  29518. updateTexture(isVisible: boolean): void;
  29519. protected _updateInternalTexture: () => void;
  29520. /**
  29521. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29522. * @param url New url.
  29523. */
  29524. updateURL(url: string): void;
  29525. /**
  29526. * Dispose the texture and release its associated resources.
  29527. */
  29528. dispose(): void;
  29529. /**
  29530. * Creates a video texture straight from a stream.
  29531. * @param scene Define the scene the texture should be created in
  29532. * @param stream Define the stream the texture should be created from
  29533. * @returns The created video texture as a promise
  29534. */
  29535. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29536. /**
  29537. * Creates a video texture straight from your WebCam video feed.
  29538. * @param scene Define the scene the texture should be created in
  29539. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29540. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29541. * @returns The created video texture as a promise
  29542. */
  29543. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29544. minWidth: number;
  29545. maxWidth: number;
  29546. minHeight: number;
  29547. maxHeight: number;
  29548. deviceId: string;
  29549. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29550. /**
  29551. * Creates a video texture straight from your WebCam video feed.
  29552. * @param scene Define the scene the texture should be created in
  29553. * @param onReady Define a callback to triggered once the texture will be ready
  29554. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29555. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29556. */
  29557. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29558. minWidth: number;
  29559. maxWidth: number;
  29560. minHeight: number;
  29561. maxHeight: number;
  29562. deviceId: string;
  29563. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29564. }
  29565. }
  29566. declare module BABYLON {
  29567. /**
  29568. * Defines the interface used by objects containing a viewport (like a camera)
  29569. */
  29570. interface IViewportOwnerLike {
  29571. /**
  29572. * Gets or sets the viewport
  29573. */
  29574. viewport: IViewportLike;
  29575. }
  29576. /**
  29577. * Interface for attribute information associated with buffer instanciation
  29578. */
  29579. export class InstancingAttributeInfo {
  29580. /**
  29581. * Index/offset of the attribute in the vertex shader
  29582. */
  29583. index: number;
  29584. /**
  29585. * size of the attribute, 1, 2, 3 or 4
  29586. */
  29587. attributeSize: number;
  29588. /**
  29589. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29590. * default is FLOAT
  29591. */
  29592. attribyteType: number;
  29593. /**
  29594. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29595. */
  29596. normalized: boolean;
  29597. /**
  29598. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29599. */
  29600. offset: number;
  29601. /**
  29602. * Name of the GLSL attribute, for debugging purpose only
  29603. */
  29604. attributeName: string;
  29605. }
  29606. /**
  29607. * Define options used to create a depth texture
  29608. */
  29609. export class DepthTextureCreationOptions {
  29610. /** Specifies whether or not a stencil should be allocated in the texture */
  29611. generateStencil?: boolean;
  29612. /** Specifies whether or not bilinear filtering is enable on the texture */
  29613. bilinearFiltering?: boolean;
  29614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29615. comparisonFunction?: number;
  29616. /** Specifies if the created texture is a cube texture */
  29617. isCube?: boolean;
  29618. }
  29619. /**
  29620. * Class used to describe the capabilities of the engine relatively to the current browser
  29621. */
  29622. export class EngineCapabilities {
  29623. /** Maximum textures units per fragment shader */
  29624. maxTexturesImageUnits: number;
  29625. /** Maximum texture units per vertex shader */
  29626. maxVertexTextureImageUnits: number;
  29627. /** Maximum textures units in the entire pipeline */
  29628. maxCombinedTexturesImageUnits: number;
  29629. /** Maximum texture size */
  29630. maxTextureSize: number;
  29631. /** Maximum cube texture size */
  29632. maxCubemapTextureSize: number;
  29633. /** Maximum render texture size */
  29634. maxRenderTextureSize: number;
  29635. /** Maximum number of vertex attributes */
  29636. maxVertexAttribs: number;
  29637. /** Maximum number of varyings */
  29638. maxVaryingVectors: number;
  29639. /** Maximum number of uniforms per vertex shader */
  29640. maxVertexUniformVectors: number;
  29641. /** Maximum number of uniforms per fragment shader */
  29642. maxFragmentUniformVectors: number;
  29643. /** Defines if standard derivates (dx/dy) are supported */
  29644. standardDerivatives: boolean;
  29645. /** Defines if s3tc texture compression is supported */
  29646. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29647. /** Defines if pvrtc texture compression is supported */
  29648. pvrtc: any;
  29649. /** Defines if etc1 texture compression is supported */
  29650. etc1: any;
  29651. /** Defines if etc2 texture compression is supported */
  29652. etc2: any;
  29653. /** Defines if astc texture compression is supported */
  29654. astc: any;
  29655. /** Defines if float textures are supported */
  29656. textureFloat: boolean;
  29657. /** Defines if vertex array objects are supported */
  29658. vertexArrayObject: boolean;
  29659. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29660. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29661. /** Gets the maximum level of anisotropy supported */
  29662. maxAnisotropy: number;
  29663. /** Defines if instancing is supported */
  29664. instancedArrays: boolean;
  29665. /** Defines if 32 bits indices are supported */
  29666. uintIndices: boolean;
  29667. /** Defines if high precision shaders are supported */
  29668. highPrecisionShaderSupported: boolean;
  29669. /** Defines if depth reading in the fragment shader is supported */
  29670. fragmentDepthSupported: boolean;
  29671. /** Defines if float texture linear filtering is supported*/
  29672. textureFloatLinearFiltering: boolean;
  29673. /** Defines if rendering to float textures is supported */
  29674. textureFloatRender: boolean;
  29675. /** Defines if half float textures are supported*/
  29676. textureHalfFloat: boolean;
  29677. /** Defines if half float texture linear filtering is supported*/
  29678. textureHalfFloatLinearFiltering: boolean;
  29679. /** Defines if rendering to half float textures is supported */
  29680. textureHalfFloatRender: boolean;
  29681. /** Defines if textureLOD shader command is supported */
  29682. textureLOD: boolean;
  29683. /** Defines if draw buffers extension is supported */
  29684. drawBuffersExtension: boolean;
  29685. /** Defines if depth textures are supported */
  29686. depthTextureExtension: boolean;
  29687. /** Defines if float color buffer are supported */
  29688. colorBufferFloat: boolean;
  29689. /** Gets disjoint timer query extension (null if not supported) */
  29690. timerQuery: EXT_disjoint_timer_query;
  29691. /** Defines if timestamp can be used with timer query */
  29692. canUseTimestampForTimerQuery: boolean;
  29693. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29694. multiview: any;
  29695. /** Function used to let the system compiles shaders in background */
  29696. parallelShaderCompile: {
  29697. COMPLETION_STATUS_KHR: number;
  29698. };
  29699. /** Max number of texture samples for MSAA */
  29700. maxMSAASamples: number;
  29701. }
  29702. /** Interface defining initialization parameters for Engine class */
  29703. export interface EngineOptions extends WebGLContextAttributes {
  29704. /**
  29705. * Defines if the engine should no exceed a specified device ratio
  29706. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29707. */
  29708. limitDeviceRatio?: number;
  29709. /**
  29710. * Defines if webvr should be enabled automatically
  29711. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29712. */
  29713. autoEnableWebVR?: boolean;
  29714. /**
  29715. * Defines if webgl2 should be turned off even if supported
  29716. * @see http://doc.babylonjs.com/features/webgl2
  29717. */
  29718. disableWebGL2Support?: boolean;
  29719. /**
  29720. * Defines if webaudio should be initialized as well
  29721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29722. */
  29723. audioEngine?: boolean;
  29724. /**
  29725. * Defines if animations should run using a deterministic lock step
  29726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29727. */
  29728. deterministicLockstep?: boolean;
  29729. /** Defines the maximum steps to use with deterministic lock step mode */
  29730. lockstepMaxSteps?: number;
  29731. /**
  29732. * Defines that engine should ignore context lost events
  29733. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29734. */
  29735. doNotHandleContextLost?: boolean;
  29736. /**
  29737. * Defines that engine should ignore modifying touch action attribute and style
  29738. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29739. */
  29740. doNotHandleTouchAction?: boolean;
  29741. /**
  29742. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29743. */
  29744. useHighPrecisionFloats?: boolean;
  29745. }
  29746. /**
  29747. * Defines the interface used by display changed events
  29748. */
  29749. export interface IDisplayChangedEventArgs {
  29750. /** Gets the vrDisplay object (if any) */
  29751. vrDisplay: Nullable<any>;
  29752. /** Gets a boolean indicating if webVR is supported */
  29753. vrSupported: boolean;
  29754. }
  29755. /**
  29756. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29757. */
  29758. export class Engine {
  29759. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29760. static ExceptionList: ({
  29761. key: string;
  29762. capture: string;
  29763. captureConstraint: number;
  29764. targets: string[];
  29765. } | {
  29766. key: string;
  29767. capture: null;
  29768. captureConstraint: null;
  29769. targets: string[];
  29770. })[];
  29771. /** Gets the list of created engines */
  29772. static readonly Instances: Engine[];
  29773. /**
  29774. * Gets the latest created engine
  29775. */
  29776. static readonly LastCreatedEngine: Nullable<Engine>;
  29777. /**
  29778. * Gets the latest created scene
  29779. */
  29780. static readonly LastCreatedScene: Nullable<Scene>;
  29781. /**
  29782. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29783. * @param flag defines which part of the materials must be marked as dirty
  29784. * @param predicate defines a predicate used to filter which materials should be affected
  29785. */
  29786. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29787. /** @hidden */
  29788. static _TextureLoaders: IInternalTextureLoader[];
  29789. /** Defines that alpha blending is disabled */
  29790. static readonly ALPHA_DISABLE: number;
  29791. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29792. static readonly ALPHA_ADD: number;
  29793. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29794. static readonly ALPHA_COMBINE: number;
  29795. /** Defines that alpha blending to DEST - SRC * DEST */
  29796. static readonly ALPHA_SUBTRACT: number;
  29797. /** Defines that alpha blending to SRC * DEST */
  29798. static readonly ALPHA_MULTIPLY: number;
  29799. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29800. static readonly ALPHA_MAXIMIZED: number;
  29801. /** Defines that alpha blending to SRC + DEST */
  29802. static readonly ALPHA_ONEONE: number;
  29803. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29804. static readonly ALPHA_PREMULTIPLIED: number;
  29805. /**
  29806. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29807. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29808. */
  29809. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29810. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29811. static readonly ALPHA_INTERPOLATE: number;
  29812. /**
  29813. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29814. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29815. */
  29816. static readonly ALPHA_SCREENMODE: number;
  29817. /** Defines that the ressource is not delayed*/
  29818. static readonly DELAYLOADSTATE_NONE: number;
  29819. /** Defines that the ressource was successfully delay loaded */
  29820. static readonly DELAYLOADSTATE_LOADED: number;
  29821. /** Defines that the ressource is currently delay loading */
  29822. static readonly DELAYLOADSTATE_LOADING: number;
  29823. /** Defines that the ressource is delayed and has not started loading */
  29824. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29825. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29826. static readonly NEVER: number;
  29827. /** 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 */
  29828. static readonly ALWAYS: number;
  29829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29830. static readonly LESS: number;
  29831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29832. static readonly EQUAL: number;
  29833. /** 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 */
  29834. static readonly LEQUAL: number;
  29835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29836. static readonly GREATER: number;
  29837. /** 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 */
  29838. static readonly GEQUAL: number;
  29839. /** 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 */
  29840. static readonly NOTEQUAL: number;
  29841. /** Passed to stencilOperation to specify that stencil value must be kept */
  29842. static readonly KEEP: number;
  29843. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29844. static readonly REPLACE: number;
  29845. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29846. static readonly INCR: number;
  29847. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29848. static readonly DECR: number;
  29849. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29850. static readonly INVERT: number;
  29851. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29852. static readonly INCR_WRAP: number;
  29853. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29854. static readonly DECR_WRAP: number;
  29855. /** Texture is not repeating outside of 0..1 UVs */
  29856. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29857. /** Texture is repeating outside of 0..1 UVs */
  29858. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29859. /** Texture is repeating and mirrored */
  29860. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29861. /** ALPHA */
  29862. static readonly TEXTUREFORMAT_ALPHA: number;
  29863. /** LUMINANCE */
  29864. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29865. /** LUMINANCE_ALPHA */
  29866. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29867. /** RGB */
  29868. static readonly TEXTUREFORMAT_RGB: number;
  29869. /** RGBA */
  29870. static readonly TEXTUREFORMAT_RGBA: number;
  29871. /** RED */
  29872. static readonly TEXTUREFORMAT_RED: number;
  29873. /** RED (2nd reference) */
  29874. static readonly TEXTUREFORMAT_R: number;
  29875. /** RG */
  29876. static readonly TEXTUREFORMAT_RG: number;
  29877. /** RED_INTEGER */
  29878. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29879. /** RED_INTEGER (2nd reference) */
  29880. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29881. /** RG_INTEGER */
  29882. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29883. /** RGB_INTEGER */
  29884. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29885. /** RGBA_INTEGER */
  29886. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29887. /** UNSIGNED_BYTE */
  29888. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29889. /** UNSIGNED_BYTE (2nd reference) */
  29890. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29891. /** FLOAT */
  29892. static readonly TEXTURETYPE_FLOAT: number;
  29893. /** HALF_FLOAT */
  29894. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29895. /** BYTE */
  29896. static readonly TEXTURETYPE_BYTE: number;
  29897. /** SHORT */
  29898. static readonly TEXTURETYPE_SHORT: number;
  29899. /** UNSIGNED_SHORT */
  29900. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29901. /** INT */
  29902. static readonly TEXTURETYPE_INT: number;
  29903. /** UNSIGNED_INT */
  29904. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29905. /** UNSIGNED_SHORT_4_4_4_4 */
  29906. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29907. /** UNSIGNED_SHORT_5_5_5_1 */
  29908. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29909. /** UNSIGNED_SHORT_5_6_5 */
  29910. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29911. /** UNSIGNED_INT_2_10_10_10_REV */
  29912. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29913. /** UNSIGNED_INT_24_8 */
  29914. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29915. /** UNSIGNED_INT_10F_11F_11F_REV */
  29916. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29917. /** UNSIGNED_INT_5_9_9_9_REV */
  29918. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29919. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29920. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29921. /** nearest is mag = nearest and min = nearest and mip = linear */
  29922. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29923. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29924. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29925. /** Trilinear is mag = linear and min = linear and mip = linear */
  29926. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29927. /** nearest is mag = nearest and min = nearest and mip = linear */
  29928. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29930. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29931. /** Trilinear is mag = linear and min = linear and mip = linear */
  29932. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29933. /** mag = nearest and min = nearest and mip = nearest */
  29934. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29935. /** mag = nearest and min = linear and mip = nearest */
  29936. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29937. /** mag = nearest and min = linear and mip = linear */
  29938. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29939. /** mag = nearest and min = linear and mip = none */
  29940. static readonly TEXTURE_NEAREST_LINEAR: number;
  29941. /** mag = nearest and min = nearest and mip = none */
  29942. static readonly TEXTURE_NEAREST_NEAREST: number;
  29943. /** mag = linear and min = nearest and mip = nearest */
  29944. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29945. /** mag = linear and min = nearest and mip = linear */
  29946. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29947. /** mag = linear and min = linear and mip = none */
  29948. static readonly TEXTURE_LINEAR_LINEAR: number;
  29949. /** mag = linear and min = nearest and mip = none */
  29950. static readonly TEXTURE_LINEAR_NEAREST: number;
  29951. /** Explicit coordinates mode */
  29952. static readonly TEXTURE_EXPLICIT_MODE: number;
  29953. /** Spherical coordinates mode */
  29954. static readonly TEXTURE_SPHERICAL_MODE: number;
  29955. /** Planar coordinates mode */
  29956. static readonly TEXTURE_PLANAR_MODE: number;
  29957. /** Cubic coordinates mode */
  29958. static readonly TEXTURE_CUBIC_MODE: number;
  29959. /** Projection coordinates mode */
  29960. static readonly TEXTURE_PROJECTION_MODE: number;
  29961. /** Skybox coordinates mode */
  29962. static readonly TEXTURE_SKYBOX_MODE: number;
  29963. /** Inverse Cubic coordinates mode */
  29964. static readonly TEXTURE_INVCUBIC_MODE: number;
  29965. /** Equirectangular coordinates mode */
  29966. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29967. /** Equirectangular Fixed coordinates mode */
  29968. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29969. /** Equirectangular Fixed Mirrored coordinates mode */
  29970. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29971. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29972. static readonly SCALEMODE_FLOOR: number;
  29973. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29974. static readonly SCALEMODE_NEAREST: number;
  29975. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29976. static readonly SCALEMODE_CEILING: number;
  29977. /**
  29978. * Returns the current npm package of the sdk
  29979. */
  29980. static readonly NpmPackage: string;
  29981. /**
  29982. * Returns the current version of the framework
  29983. */
  29984. static readonly Version: string;
  29985. /**
  29986. * Returns a string describing the current engine
  29987. */
  29988. readonly description: string;
  29989. /**
  29990. * Gets or sets the epsilon value used by collision engine
  29991. */
  29992. static CollisionsEpsilon: number;
  29993. /**
  29994. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29995. */
  29996. static ShadersRepository: string;
  29997. /**
  29998. * Method called to create the default loading screen.
  29999. * This can be overriden in your own app.
  30000. * @param canvas The rendering canvas element
  30001. * @returns The loading screen
  30002. */
  30003. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30004. /**
  30005. * Method called to create the default rescale post process on each engine.
  30006. */
  30007. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30008. /** @hidden */
  30009. _shaderProcessor: IShaderProcessor;
  30010. /**
  30011. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30012. */
  30013. forcePOTTextures: boolean;
  30014. /**
  30015. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30016. */
  30017. isFullscreen: boolean;
  30018. /**
  30019. * Gets a boolean indicating if the pointer is currently locked
  30020. */
  30021. isPointerLock: boolean;
  30022. /**
  30023. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30024. */
  30025. cullBackFaces: boolean;
  30026. /**
  30027. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30028. */
  30029. renderEvenInBackground: boolean;
  30030. /**
  30031. * Gets or sets a boolean indicating that cache can be kept between frames
  30032. */
  30033. preventCacheWipeBetweenFrames: boolean;
  30034. /**
  30035. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30036. **/
  30037. enableOfflineSupport: boolean;
  30038. /**
  30039. * 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)
  30040. **/
  30041. disableManifestCheck: boolean;
  30042. /**
  30043. * Gets the list of created scenes
  30044. */
  30045. scenes: Scene[];
  30046. /**
  30047. * Event raised when a new scene is created
  30048. */
  30049. onNewSceneAddedObservable: Observable<Scene>;
  30050. /**
  30051. * Gets the list of created postprocesses
  30052. */
  30053. postProcesses: PostProcess[];
  30054. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30055. validateShaderPrograms: boolean;
  30056. /**
  30057. * Observable event triggered each time the rendering canvas is resized
  30058. */
  30059. onResizeObservable: Observable<Engine>;
  30060. /**
  30061. * Observable event triggered each time the canvas loses focus
  30062. */
  30063. onCanvasBlurObservable: Observable<Engine>;
  30064. /**
  30065. * Observable event triggered each time the canvas gains focus
  30066. */
  30067. onCanvasFocusObservable: Observable<Engine>;
  30068. /**
  30069. * Observable event triggered each time the canvas receives pointerout event
  30070. */
  30071. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30072. /**
  30073. * Observable event triggered before each texture is initialized
  30074. */
  30075. onBeforeTextureInitObservable: Observable<Texture>;
  30076. /**
  30077. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30078. */
  30079. disableUniformBuffers: boolean;
  30080. /** @hidden */
  30081. _uniformBuffers: UniformBuffer[];
  30082. /**
  30083. * Gets a boolean indicating that the engine supports uniform buffers
  30084. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30085. */
  30086. readonly supportsUniformBuffers: boolean;
  30087. /**
  30088. * Observable raised when the engine begins a new frame
  30089. */
  30090. onBeginFrameObservable: Observable<Engine>;
  30091. /**
  30092. * If set, will be used to request the next animation frame for the render loop
  30093. */
  30094. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30095. /**
  30096. * Observable raised when the engine ends the current frame
  30097. */
  30098. onEndFrameObservable: Observable<Engine>;
  30099. /**
  30100. * Observable raised when the engine is about to compile a shader
  30101. */
  30102. onBeforeShaderCompilationObservable: Observable<Engine>;
  30103. /**
  30104. * Observable raised when the engine has jsut compiled a shader
  30105. */
  30106. onAfterShaderCompilationObservable: Observable<Engine>;
  30107. /** @hidden */
  30108. _gl: WebGLRenderingContext;
  30109. private _renderingCanvas;
  30110. private _windowIsBackground;
  30111. private _webGLVersion;
  30112. protected _highPrecisionShadersAllowed: boolean;
  30113. /** @hidden */
  30114. readonly _shouldUseHighPrecisionShader: boolean;
  30115. /**
  30116. * Gets a boolean indicating that only power of 2 textures are supported
  30117. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30118. */
  30119. readonly needPOTTextures: boolean;
  30120. /** @hidden */
  30121. _badOS: boolean;
  30122. /** @hidden */
  30123. _badDesktopOS: boolean;
  30124. /**
  30125. * Gets the audio engine
  30126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30127. * @ignorenaming
  30128. */
  30129. static audioEngine: IAudioEngine;
  30130. /**
  30131. * Default AudioEngine factory responsible of creating the Audio Engine.
  30132. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30133. */
  30134. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30135. /**
  30136. * Default offline support factory responsible of creating a tool used to store data locally.
  30137. * By default, this will create a Database object if the workload has been embedded.
  30138. */
  30139. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30140. private _onFocus;
  30141. private _onBlur;
  30142. private _onCanvasPointerOut;
  30143. private _onCanvasBlur;
  30144. private _onCanvasFocus;
  30145. private _onFullscreenChange;
  30146. private _onPointerLockChange;
  30147. private _hardwareScalingLevel;
  30148. /** @hidden */
  30149. _caps: EngineCapabilities;
  30150. private _pointerLockRequested;
  30151. private _isStencilEnable;
  30152. private _colorWrite;
  30153. private _loadingScreen;
  30154. /** @hidden */
  30155. _drawCalls: PerfCounter;
  30156. private _glVersion;
  30157. private _glRenderer;
  30158. private _glVendor;
  30159. private _videoTextureSupported;
  30160. private _renderingQueueLaunched;
  30161. private _activeRenderLoops;
  30162. private _deterministicLockstep;
  30163. private _lockstepMaxSteps;
  30164. /**
  30165. * Observable signaled when a context lost event is raised
  30166. */
  30167. onContextLostObservable: Observable<Engine>;
  30168. /**
  30169. * Observable signaled when a context restored event is raised
  30170. */
  30171. onContextRestoredObservable: Observable<Engine>;
  30172. private _onContextLost;
  30173. private _onContextRestored;
  30174. private _contextWasLost;
  30175. /** @hidden */
  30176. _doNotHandleContextLost: boolean;
  30177. /**
  30178. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30180. */
  30181. doNotHandleContextLost: boolean;
  30182. private _performanceMonitor;
  30183. private _fps;
  30184. private _deltaTime;
  30185. /**
  30186. * Turn this value on if you want to pause FPS computation when in background
  30187. */
  30188. disablePerformanceMonitorInBackground: boolean;
  30189. /**
  30190. * Gets the performance monitor attached to this engine
  30191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30192. */
  30193. readonly performanceMonitor: PerformanceMonitor;
  30194. /**
  30195. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30196. */
  30197. disableVertexArrayObjects: boolean;
  30198. /** @hidden */
  30199. protected _depthCullingState: _DepthCullingState;
  30200. /** @hidden */
  30201. protected _stencilState: _StencilState;
  30202. /** @hidden */
  30203. protected _alphaState: _AlphaState;
  30204. /** @hidden */
  30205. protected _alphaMode: number;
  30206. /** @hidden */
  30207. _internalTexturesCache: InternalTexture[];
  30208. /** @hidden */
  30209. protected _activeChannel: number;
  30210. private _currentTextureChannel;
  30211. /** @hidden */
  30212. protected _boundTexturesCache: {
  30213. [key: string]: Nullable<InternalTexture>;
  30214. };
  30215. /** @hidden */
  30216. protected _currentEffect: Nullable<Effect>;
  30217. /** @hidden */
  30218. protected _currentProgram: Nullable<WebGLProgram>;
  30219. private _compiledEffects;
  30220. private _vertexAttribArraysEnabled;
  30221. /** @hidden */
  30222. protected _cachedViewport: Nullable<IViewportLike>;
  30223. private _cachedVertexArrayObject;
  30224. /** @hidden */
  30225. protected _cachedVertexBuffers: any;
  30226. /** @hidden */
  30227. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30228. /** @hidden */
  30229. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30230. /** @hidden */
  30231. _currentRenderTarget: Nullable<InternalTexture>;
  30232. private _uintIndicesCurrentlySet;
  30233. private _currentBoundBuffer;
  30234. /** @hidden */
  30235. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30236. private _currentBufferPointers;
  30237. private _currentInstanceLocations;
  30238. private _currentInstanceBuffers;
  30239. private _textureUnits;
  30240. /** @hidden */
  30241. _workingCanvas: Nullable<HTMLCanvasElement>;
  30242. /** @hidden */
  30243. _workingContext: Nullable<CanvasRenderingContext2D>;
  30244. private _rescalePostProcess;
  30245. private _dummyFramebuffer;
  30246. private _externalData;
  30247. /** @hidden */
  30248. _bindedRenderFunction: any;
  30249. private _vaoRecordInProgress;
  30250. private _mustWipeVertexAttributes;
  30251. private _emptyTexture;
  30252. private _emptyCubeTexture;
  30253. private _emptyTexture3D;
  30254. /** @hidden */
  30255. _frameHandler: number;
  30256. private _nextFreeTextureSlots;
  30257. private _maxSimultaneousTextures;
  30258. private _activeRequests;
  30259. private _texturesSupported;
  30260. /** @hidden */
  30261. _textureFormatInUse: Nullable<string>;
  30262. /**
  30263. * Gets the list of texture formats supported
  30264. */
  30265. readonly texturesSupported: Array<string>;
  30266. /**
  30267. * Gets the list of texture formats in use
  30268. */
  30269. readonly textureFormatInUse: Nullable<string>;
  30270. /**
  30271. * Gets the current viewport
  30272. */
  30273. readonly currentViewport: Nullable<IViewportLike>;
  30274. /**
  30275. * Gets the default empty texture
  30276. */
  30277. readonly emptyTexture: InternalTexture;
  30278. /**
  30279. * Gets the default empty 3D texture
  30280. */
  30281. readonly emptyTexture3D: InternalTexture;
  30282. /**
  30283. * Gets the default empty cube texture
  30284. */
  30285. readonly emptyCubeTexture: InternalTexture;
  30286. /**
  30287. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30288. */
  30289. readonly premultipliedAlpha: boolean;
  30290. /**
  30291. * Creates a new engine
  30292. * @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
  30293. * @param antialias defines enable antialiasing (default: false)
  30294. * @param options defines further options to be sent to the getContext() function
  30295. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30296. */
  30297. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30298. /**
  30299. * Initializes a webVR display and starts listening to display change events
  30300. * The onVRDisplayChangedObservable will be notified upon these changes
  30301. * @returns The onVRDisplayChangedObservable
  30302. */
  30303. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30304. /** @hidden */
  30305. _prepareVRComponent(): void;
  30306. /** @hidden */
  30307. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30308. /** @hidden */
  30309. _submitVRFrame(): void;
  30310. /**
  30311. * Call this function to leave webVR mode
  30312. * Will do nothing if webVR is not supported or if there is no webVR device
  30313. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30314. */
  30315. disableVR(): void;
  30316. /**
  30317. * Gets a boolean indicating that the system is in VR mode and is presenting
  30318. * @returns true if VR mode is engaged
  30319. */
  30320. isVRPresenting(): boolean;
  30321. /** @hidden */
  30322. _requestVRFrame(): void;
  30323. private _disableTouchAction;
  30324. private _rebuildInternalTextures;
  30325. private _rebuildEffects;
  30326. /**
  30327. * Gets a boolean indicating if all created effects are ready
  30328. * @returns true if all effects are ready
  30329. */
  30330. areAllEffectsReady(): boolean;
  30331. private _rebuildBuffers;
  30332. private _initGLContext;
  30333. /**
  30334. * Gets version of the current webGL context
  30335. */
  30336. readonly webGLVersion: number;
  30337. /**
  30338. * Gets a string idenfifying the name of the class
  30339. * @returns "Engine" string
  30340. */
  30341. getClassName(): string;
  30342. /**
  30343. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30344. */
  30345. readonly isStencilEnable: boolean;
  30346. /** @hidden */
  30347. _prepareWorkingCanvas(): void;
  30348. /**
  30349. * Reset the texture cache to empty state
  30350. */
  30351. resetTextureCache(): void;
  30352. /**
  30353. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30355. * @returns true if engine is in deterministic lock step mode
  30356. */
  30357. isDeterministicLockStep(): boolean;
  30358. /**
  30359. * Gets the max steps when engine is running in deterministic lock step
  30360. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30361. * @returns the max steps
  30362. */
  30363. getLockstepMaxSteps(): number;
  30364. /**
  30365. * Gets an object containing information about the current webGL context
  30366. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30367. */
  30368. getGlInfo(): {
  30369. vendor: string;
  30370. renderer: string;
  30371. version: string;
  30372. };
  30373. /**
  30374. * Gets current aspect ratio
  30375. * @param viewportOwner defines the camera to use to get the aspect ratio
  30376. * @param useScreen defines if screen size must be used (or the current render target if any)
  30377. * @returns a number defining the aspect ratio
  30378. */
  30379. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30380. /**
  30381. * Gets current screen aspect ratio
  30382. * @returns a number defining the aspect ratio
  30383. */
  30384. getScreenAspectRatio(): number;
  30385. /**
  30386. * Gets the current render width
  30387. * @param useScreen defines if screen size must be used (or the current render target if any)
  30388. * @returns a number defining the current render width
  30389. */
  30390. getRenderWidth(useScreen?: boolean): number;
  30391. /**
  30392. * Gets the current render height
  30393. * @param useScreen defines if screen size must be used (or the current render target if any)
  30394. * @returns a number defining the current render height
  30395. */
  30396. getRenderHeight(useScreen?: boolean): number;
  30397. /**
  30398. * Gets the HTML canvas attached with the current webGL context
  30399. * @returns a HTML canvas
  30400. */
  30401. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30402. /**
  30403. * Gets host window
  30404. * @returns the host window object
  30405. */
  30406. getHostWindow(): Window;
  30407. /**
  30408. * Gets host document
  30409. * @returns the host document object
  30410. */
  30411. getHostDocument(): Document;
  30412. /**
  30413. * Gets the client rect of the HTML canvas attached with the current webGL context
  30414. * @returns a client rectanglee
  30415. */
  30416. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30417. /**
  30418. * Defines the hardware scaling level.
  30419. * By default the hardware scaling level is computed from the window device ratio.
  30420. * 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.
  30421. * @param level defines the level to use
  30422. */
  30423. setHardwareScalingLevel(level: number): void;
  30424. /**
  30425. * Gets the current hardware scaling level.
  30426. * By default the hardware scaling level is computed from the window device ratio.
  30427. * 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.
  30428. * @returns a number indicating the current hardware scaling level
  30429. */
  30430. getHardwareScalingLevel(): number;
  30431. /**
  30432. * Gets the list of loaded textures
  30433. * @returns an array containing all loaded textures
  30434. */
  30435. getLoadedTexturesCache(): InternalTexture[];
  30436. /**
  30437. * Gets the object containing all engine capabilities
  30438. * @returns the EngineCapabilities object
  30439. */
  30440. getCaps(): EngineCapabilities;
  30441. /**
  30442. * Gets the current depth function
  30443. * @returns a number defining the depth function
  30444. */
  30445. getDepthFunction(): Nullable<number>;
  30446. /**
  30447. * Sets the current depth function
  30448. * @param depthFunc defines the function to use
  30449. */
  30450. setDepthFunction(depthFunc: number): void;
  30451. /**
  30452. * Sets the current depth function to GREATER
  30453. */
  30454. setDepthFunctionToGreater(): void;
  30455. /**
  30456. * Sets the current depth function to GEQUAL
  30457. */
  30458. setDepthFunctionToGreaterOrEqual(): void;
  30459. /**
  30460. * Sets the current depth function to LESS
  30461. */
  30462. setDepthFunctionToLess(): void;
  30463. private _cachedStencilBuffer;
  30464. private _cachedStencilFunction;
  30465. private _cachedStencilMask;
  30466. private _cachedStencilOperationPass;
  30467. private _cachedStencilOperationFail;
  30468. private _cachedStencilOperationDepthFail;
  30469. private _cachedStencilReference;
  30470. /**
  30471. * Caches the the state of the stencil buffer
  30472. */
  30473. cacheStencilState(): void;
  30474. /**
  30475. * Restores the state of the stencil buffer
  30476. */
  30477. restoreStencilState(): void;
  30478. /**
  30479. * Sets the current depth function to LEQUAL
  30480. */
  30481. setDepthFunctionToLessOrEqual(): void;
  30482. /**
  30483. * Gets a boolean indicating if stencil buffer is enabled
  30484. * @returns the current stencil buffer state
  30485. */
  30486. getStencilBuffer(): boolean;
  30487. /**
  30488. * Enable or disable the stencil buffer
  30489. * @param enable defines if the stencil buffer must be enabled or disabled
  30490. */
  30491. setStencilBuffer(enable: boolean): void;
  30492. /**
  30493. * Gets the current stencil mask
  30494. * @returns a number defining the new stencil mask to use
  30495. */
  30496. getStencilMask(): number;
  30497. /**
  30498. * Sets the current stencil mask
  30499. * @param mask defines the new stencil mask to use
  30500. */
  30501. setStencilMask(mask: number): void;
  30502. /**
  30503. * Gets the current stencil function
  30504. * @returns a number defining the stencil function to use
  30505. */
  30506. getStencilFunction(): number;
  30507. /**
  30508. * Gets the current stencil reference value
  30509. * @returns a number defining the stencil reference value to use
  30510. */
  30511. getStencilFunctionReference(): number;
  30512. /**
  30513. * Gets the current stencil mask
  30514. * @returns a number defining the stencil mask to use
  30515. */
  30516. getStencilFunctionMask(): number;
  30517. /**
  30518. * Sets the current stencil function
  30519. * @param stencilFunc defines the new stencil function to use
  30520. */
  30521. setStencilFunction(stencilFunc: number): void;
  30522. /**
  30523. * Sets the current stencil reference
  30524. * @param reference defines the new stencil reference to use
  30525. */
  30526. setStencilFunctionReference(reference: number): void;
  30527. /**
  30528. * Sets the current stencil mask
  30529. * @param mask defines the new stencil mask to use
  30530. */
  30531. setStencilFunctionMask(mask: number): void;
  30532. /**
  30533. * Gets the current stencil operation when stencil fails
  30534. * @returns a number defining stencil operation to use when stencil fails
  30535. */
  30536. getStencilOperationFail(): number;
  30537. /**
  30538. * Gets the current stencil operation when depth fails
  30539. * @returns a number defining stencil operation to use when depth fails
  30540. */
  30541. getStencilOperationDepthFail(): number;
  30542. /**
  30543. * Gets the current stencil operation when stencil passes
  30544. * @returns a number defining stencil operation to use when stencil passes
  30545. */
  30546. getStencilOperationPass(): number;
  30547. /**
  30548. * Sets the stencil operation to use when stencil fails
  30549. * @param operation defines the stencil operation to use when stencil fails
  30550. */
  30551. setStencilOperationFail(operation: number): void;
  30552. /**
  30553. * Sets the stencil operation to use when depth fails
  30554. * @param operation defines the stencil operation to use when depth fails
  30555. */
  30556. setStencilOperationDepthFail(operation: number): void;
  30557. /**
  30558. * Sets the stencil operation to use when stencil passes
  30559. * @param operation defines the stencil operation to use when stencil passes
  30560. */
  30561. setStencilOperationPass(operation: number): void;
  30562. /**
  30563. * Sets a boolean indicating if the dithering state is enabled or disabled
  30564. * @param value defines the dithering state
  30565. */
  30566. setDitheringState(value: boolean): void;
  30567. /**
  30568. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30569. * @param value defines the rasterizer state
  30570. */
  30571. setRasterizerState(value: boolean): void;
  30572. /**
  30573. * stop executing a render loop function and remove it from the execution array
  30574. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30575. */
  30576. stopRenderLoop(renderFunction?: () => void): void;
  30577. /** @hidden */
  30578. _renderLoop(): void;
  30579. /**
  30580. * Register and execute a render loop. The engine can have more than one render function
  30581. * @param renderFunction defines the function to continuously execute
  30582. */
  30583. runRenderLoop(renderFunction: () => void): void;
  30584. /**
  30585. * Toggle full screen mode
  30586. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30587. */
  30588. switchFullscreen(requestPointerLock: boolean): void;
  30589. /**
  30590. * Enters full screen mode
  30591. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30592. */
  30593. enterFullscreen(requestPointerLock: boolean): void;
  30594. /**
  30595. * Exits full screen mode
  30596. */
  30597. exitFullscreen(): void;
  30598. /**
  30599. * Enters Pointerlock mode
  30600. */
  30601. enterPointerlock(): void;
  30602. /**
  30603. * Exits Pointerlock mode
  30604. */
  30605. exitPointerlock(): void;
  30606. /**
  30607. * Clear the current render buffer or the current render target (if any is set up)
  30608. * @param color defines the color to use
  30609. * @param backBuffer defines if the back buffer must be cleared
  30610. * @param depth defines if the depth buffer must be cleared
  30611. * @param stencil defines if the stencil buffer must be cleared
  30612. */
  30613. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30614. /**
  30615. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30616. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30617. * @param y defines the y-coordinate of the corner of the clear rectangle
  30618. * @param width defines the width of the clear rectangle
  30619. * @param height defines the height of the clear rectangle
  30620. * @param clearColor defines the clear color
  30621. */
  30622. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30623. /**
  30624. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30625. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30626. * @param y defines the y-coordinate of the corner of the clear rectangle
  30627. * @param width defines the width of the clear rectangle
  30628. * @param height defines the height of the clear rectangle
  30629. */
  30630. enableScissor(x: number, y: number, width: number, height: number): void;
  30631. /**
  30632. * Disable previously set scissor test rectangle
  30633. */
  30634. disableScissor(): void;
  30635. private _viewportCached;
  30636. /** @hidden */
  30637. _viewport(x: number, y: number, width: number, height: number): void;
  30638. /**
  30639. * Set the WebGL's viewport
  30640. * @param viewport defines the viewport element to be used
  30641. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30642. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30643. */
  30644. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30645. /**
  30646. * Directly set the WebGL Viewport
  30647. * @param x defines the x coordinate of the viewport (in screen space)
  30648. * @param y defines the y coordinate of the viewport (in screen space)
  30649. * @param width defines the width of the viewport (in screen space)
  30650. * @param height defines the height of the viewport (in screen space)
  30651. * @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
  30652. */
  30653. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30654. /**
  30655. * Begin a new frame
  30656. */
  30657. beginFrame(): void;
  30658. /**
  30659. * Enf the current frame
  30660. */
  30661. endFrame(): void;
  30662. /**
  30663. * Resize the view according to the canvas' size
  30664. */
  30665. resize(): void;
  30666. /**
  30667. * Force a specific size of the canvas
  30668. * @param width defines the new canvas' width
  30669. * @param height defines the new canvas' height
  30670. */
  30671. setSize(width: number, height: number): void;
  30672. /**
  30673. * Binds the frame buffer to the specified texture.
  30674. * @param texture The texture to render to or null for the default canvas
  30675. * @param faceIndex The face of the texture to render to in case of cube texture
  30676. * @param requiredWidth The width of the target to render to
  30677. * @param requiredHeight The height of the target to render to
  30678. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30679. * @param depthStencilTexture The depth stencil texture to use to render
  30680. * @param lodLevel defines le lod level to bind to the frame buffer
  30681. */
  30682. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30683. /** @hidden */
  30684. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30685. /**
  30686. * Unbind the current render target texture from the webGL context
  30687. * @param texture defines the render target texture to unbind
  30688. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30689. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30690. */
  30691. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30692. /**
  30693. * Force the mipmap generation for the given render target texture
  30694. * @param texture defines the render target texture to use
  30695. */
  30696. generateMipMapsForCubemap(texture: InternalTexture): void;
  30697. /**
  30698. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30699. */
  30700. flushFramebuffer(): void;
  30701. /**
  30702. * Unbind the current render target and bind the default framebuffer
  30703. */
  30704. restoreDefaultFramebuffer(): void;
  30705. /**
  30706. * Create an uniform buffer
  30707. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30708. * @param elements defines the content of the uniform buffer
  30709. * @returns the webGL uniform buffer
  30710. */
  30711. createUniformBuffer(elements: FloatArray): DataBuffer;
  30712. /**
  30713. * Create a dynamic uniform buffer
  30714. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30715. * @param elements defines the content of the uniform buffer
  30716. * @returns the webGL uniform buffer
  30717. */
  30718. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30719. /**
  30720. * Update an existing uniform buffer
  30721. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30722. * @param uniformBuffer defines the target uniform buffer
  30723. * @param elements defines the content to update
  30724. * @param offset defines the offset in the uniform buffer where update should start
  30725. * @param count defines the size of the data to update
  30726. */
  30727. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30728. private _resetVertexBufferBinding;
  30729. /**
  30730. * Creates a vertex buffer
  30731. * @param data the data for the vertex buffer
  30732. * @returns the new WebGL static buffer
  30733. */
  30734. createVertexBuffer(data: DataArray): DataBuffer;
  30735. /**
  30736. * Creates a dynamic vertex buffer
  30737. * @param data the data for the dynamic vertex buffer
  30738. * @returns the new WebGL dynamic buffer
  30739. */
  30740. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30741. /**
  30742. * Update a dynamic index buffer
  30743. * @param indexBuffer defines the target index buffer
  30744. * @param indices defines the data to update
  30745. * @param offset defines the offset in the target index buffer where update should start
  30746. */
  30747. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30748. /**
  30749. * Updates a dynamic vertex buffer.
  30750. * @param vertexBuffer the vertex buffer to update
  30751. * @param data the data used to update the vertex buffer
  30752. * @param byteOffset the byte offset of the data
  30753. * @param byteLength the byte length of the data
  30754. */
  30755. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30756. private _resetIndexBufferBinding;
  30757. /**
  30758. * Creates a new index buffer
  30759. * @param indices defines the content of the index buffer
  30760. * @param updatable defines if the index buffer must be updatable
  30761. * @returns a new webGL buffer
  30762. */
  30763. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30764. /**
  30765. * Bind a webGL buffer to the webGL context
  30766. * @param buffer defines the buffer to bind
  30767. */
  30768. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30769. /**
  30770. * Bind an uniform buffer to the current webGL context
  30771. * @param buffer defines the buffer to bind
  30772. */
  30773. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30774. /**
  30775. * Bind a buffer to the current webGL context at a given location
  30776. * @param buffer defines the buffer to bind
  30777. * @param location defines the index where to bind the buffer
  30778. */
  30779. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30780. /**
  30781. * Bind a specific block at a given index in a specific shader program
  30782. * @param pipelineContext defines the pipeline context to use
  30783. * @param blockName defines the block name
  30784. * @param index defines the index where to bind the block
  30785. */
  30786. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30787. private bindIndexBuffer;
  30788. private bindBuffer;
  30789. /**
  30790. * update the bound buffer with the given data
  30791. * @param data defines the data to update
  30792. */
  30793. updateArrayBuffer(data: Float32Array): void;
  30794. private _vertexAttribPointer;
  30795. private _bindIndexBufferWithCache;
  30796. private _bindVertexBuffersAttributes;
  30797. /**
  30798. * Records a vertex array object
  30799. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30800. * @param vertexBuffers defines the list of vertex buffers to store
  30801. * @param indexBuffer defines the index buffer to store
  30802. * @param effect defines the effect to store
  30803. * @returns the new vertex array object
  30804. */
  30805. recordVertexArrayObject(vertexBuffers: {
  30806. [key: string]: VertexBuffer;
  30807. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30808. /**
  30809. * Bind a specific vertex array object
  30810. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30811. * @param vertexArrayObject defines the vertex array object to bind
  30812. * @param indexBuffer defines the index buffer to bind
  30813. */
  30814. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30815. /**
  30816. * Bind webGl buffers directly to the webGL context
  30817. * @param vertexBuffer defines the vertex buffer to bind
  30818. * @param indexBuffer defines the index buffer to bind
  30819. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30820. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30821. * @param effect defines the effect associated with the vertex buffer
  30822. */
  30823. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30824. private _unbindVertexArrayObject;
  30825. /**
  30826. * Bind a list of vertex buffers to the webGL context
  30827. * @param vertexBuffers defines the list of vertex buffers to bind
  30828. * @param indexBuffer defines the index buffer to bind
  30829. * @param effect defines the effect associated with the vertex buffers
  30830. */
  30831. bindBuffers(vertexBuffers: {
  30832. [key: string]: Nullable<VertexBuffer>;
  30833. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30834. /**
  30835. * Unbind all instance attributes
  30836. */
  30837. unbindInstanceAttributes(): void;
  30838. /**
  30839. * Release and free the memory of a vertex array object
  30840. * @param vao defines the vertex array object to delete
  30841. */
  30842. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30843. /** @hidden */
  30844. _releaseBuffer(buffer: DataBuffer): boolean;
  30845. /**
  30846. * Creates a webGL buffer to use with instanciation
  30847. * @param capacity defines the size of the buffer
  30848. * @returns the webGL buffer
  30849. */
  30850. createInstancesBuffer(capacity: number): DataBuffer;
  30851. /**
  30852. * Delete a webGL buffer used with instanciation
  30853. * @param buffer defines the webGL buffer to delete
  30854. */
  30855. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30856. /**
  30857. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30858. * @param instancesBuffer defines the webGL buffer to update and bind
  30859. * @param data defines the data to store in the buffer
  30860. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30861. */
  30862. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30863. /**
  30864. * Apply all cached states (depth, culling, stencil and alpha)
  30865. */
  30866. applyStates(): void;
  30867. /**
  30868. * Send a draw order
  30869. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30870. * @param indexStart defines the starting index
  30871. * @param indexCount defines the number of index to draw
  30872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30873. */
  30874. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30875. /**
  30876. * Draw a list of points
  30877. * @param verticesStart defines the index of first vertex to draw
  30878. * @param verticesCount defines the count of vertices to draw
  30879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30880. */
  30881. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30882. /**
  30883. * Draw a list of unindexed primitives
  30884. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30885. * @param verticesStart defines the index of first vertex to draw
  30886. * @param verticesCount defines the count of vertices to draw
  30887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30888. */
  30889. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30890. /**
  30891. * Draw a list of indexed primitives
  30892. * @param fillMode defines the primitive to use
  30893. * @param indexStart defines the starting index
  30894. * @param indexCount defines the number of index to draw
  30895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30896. */
  30897. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30898. /**
  30899. * Draw a list of unindexed primitives
  30900. * @param fillMode defines the primitive to use
  30901. * @param verticesStart defines the index of first vertex to draw
  30902. * @param verticesCount defines the count of vertices to draw
  30903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30904. */
  30905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30906. private _drawMode;
  30907. /** @hidden */
  30908. _releaseEffect(effect: Effect): void;
  30909. /** @hidden */
  30910. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30911. /**
  30912. * Create a new effect (used to store vertex/fragment shaders)
  30913. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30914. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30915. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30916. * @param samplers defines an array of string used to represent textures
  30917. * @param defines defines the string containing the defines to use to compile the shaders
  30918. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30919. * @param onCompiled defines a function to call when the effect creation is successful
  30920. * @param onError defines a function to call when the effect creation has failed
  30921. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30922. * @returns the new Effect
  30923. */
  30924. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30925. private _compileShader;
  30926. private _compileRawShader;
  30927. /**
  30928. * Directly creates a webGL program
  30929. * @param pipelineContext defines the pipeline context to attach to
  30930. * @param vertexCode defines the vertex shader code to use
  30931. * @param fragmentCode defines the fragment shader code to use
  30932. * @param context defines the webGL context to use (if not set, the current one will be used)
  30933. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30934. * @returns the new webGL program
  30935. */
  30936. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30937. /**
  30938. * Creates a webGL program
  30939. * @param pipelineContext defines the pipeline context to attach to
  30940. * @param vertexCode defines the vertex shader code to use
  30941. * @param fragmentCode defines the fragment shader code to use
  30942. * @param defines defines the string containing the defines to use to compile the shaders
  30943. * @param context defines the webGL context to use (if not set, the current one will be used)
  30944. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30945. * @returns the new webGL program
  30946. */
  30947. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30948. /**
  30949. * Creates a new pipeline context
  30950. * @returns the new pipeline
  30951. */
  30952. createPipelineContext(): WebGLPipelineContext;
  30953. private _createShaderProgram;
  30954. private _finalizePipelineContext;
  30955. /** @hidden */
  30956. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30957. /** @hidden */
  30958. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30959. /** @hidden */
  30960. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30961. /**
  30962. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30963. * @param pipelineContext defines the pipeline context to use
  30964. * @param uniformsNames defines the list of uniform names
  30965. * @returns an array of webGL uniform locations
  30966. */
  30967. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30968. /**
  30969. * Gets the lsit of active attributes for a given webGL program
  30970. * @param pipelineContext defines the pipeline context to use
  30971. * @param attributesNames defines the list of attribute names to get
  30972. * @returns an array of indices indicating the offset of each attribute
  30973. */
  30974. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30975. /**
  30976. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30977. * @param effect defines the effect to activate
  30978. */
  30979. enableEffect(effect: Nullable<Effect>): void;
  30980. /**
  30981. * Set the value of an uniform to an array of int32
  30982. * @param uniform defines the webGL uniform location where to store the value
  30983. * @param array defines the array of int32 to store
  30984. */
  30985. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30986. /**
  30987. * Set the value of an uniform to an array of int32 (stored as vec2)
  30988. * @param uniform defines the webGL uniform location where to store the value
  30989. * @param array defines the array of int32 to store
  30990. */
  30991. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30992. /**
  30993. * Set the value of an uniform to an array of int32 (stored as vec3)
  30994. * @param uniform defines the webGL uniform location where to store the value
  30995. * @param array defines the array of int32 to store
  30996. */
  30997. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30998. /**
  30999. * Set the value of an uniform to an array of int32 (stored as vec4)
  31000. * @param uniform defines the webGL uniform location where to store the value
  31001. * @param array defines the array of int32 to store
  31002. */
  31003. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31004. /**
  31005. * Set the value of an uniform to an array of float32
  31006. * @param uniform defines the webGL uniform location where to store the value
  31007. * @param array defines the array of float32 to store
  31008. */
  31009. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31010. /**
  31011. * Set the value of an uniform to an array of float32 (stored as vec2)
  31012. * @param uniform defines the webGL uniform location where to store the value
  31013. * @param array defines the array of float32 to store
  31014. */
  31015. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31016. /**
  31017. * Set the value of an uniform to an array of float32 (stored as vec3)
  31018. * @param uniform defines the webGL uniform location where to store the value
  31019. * @param array defines the array of float32 to store
  31020. */
  31021. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31022. /**
  31023. * Set the value of an uniform to an array of float32 (stored as vec4)
  31024. * @param uniform defines the webGL uniform location where to store the value
  31025. * @param array defines the array of float32 to store
  31026. */
  31027. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31028. /**
  31029. * Set the value of an uniform to an array of number
  31030. * @param uniform defines the webGL uniform location where to store the value
  31031. * @param array defines the array of number to store
  31032. */
  31033. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31034. /**
  31035. * Set the value of an uniform to an array of number (stored as vec2)
  31036. * @param uniform defines the webGL uniform location where to store the value
  31037. * @param array defines the array of number to store
  31038. */
  31039. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31040. /**
  31041. * Set the value of an uniform to an array of number (stored as vec3)
  31042. * @param uniform defines the webGL uniform location where to store the value
  31043. * @param array defines the array of number to store
  31044. */
  31045. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31046. /**
  31047. * Set the value of an uniform to an array of number (stored as vec4)
  31048. * @param uniform defines the webGL uniform location where to store the value
  31049. * @param array defines the array of number to store
  31050. */
  31051. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31052. /**
  31053. * Set the value of an uniform to an array of float32 (stored as matrices)
  31054. * @param uniform defines the webGL uniform location where to store the value
  31055. * @param matrices defines the array of float32 to store
  31056. */
  31057. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31058. /**
  31059. * Set the value of an uniform to a matrix (3x3)
  31060. * @param uniform defines the webGL uniform location where to store the value
  31061. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31062. */
  31063. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31064. /**
  31065. * Set the value of an uniform to a matrix (2x2)
  31066. * @param uniform defines the webGL uniform location where to store the value
  31067. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31068. */
  31069. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31070. /**
  31071. * Set the value of an uniform to a number (int)
  31072. * @param uniform defines the webGL uniform location where to store the value
  31073. * @param value defines the int number to store
  31074. */
  31075. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31076. /**
  31077. * Set the value of an uniform to a number (float)
  31078. * @param uniform defines the webGL uniform location where to store the value
  31079. * @param value defines the float number to store
  31080. */
  31081. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31082. /**
  31083. * Set the value of an uniform to a vec2
  31084. * @param uniform defines the webGL uniform location where to store the value
  31085. * @param x defines the 1st component of the value
  31086. * @param y defines the 2nd component of the value
  31087. */
  31088. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31089. /**
  31090. * Set the value of an uniform to a vec3
  31091. * @param uniform defines the webGL uniform location where to store the value
  31092. * @param x defines the 1st component of the value
  31093. * @param y defines the 2nd component of the value
  31094. * @param z defines the 3rd component of the value
  31095. */
  31096. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31097. /**
  31098. * Set the value of an uniform to a boolean
  31099. * @param uniform defines the webGL uniform location where to store the value
  31100. * @param bool defines the boolean to store
  31101. */
  31102. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31103. /**
  31104. * Set the value of an uniform to a vec4
  31105. * @param uniform defines the webGL uniform location where to store the value
  31106. * @param x defines the 1st component of the value
  31107. * @param y defines the 2nd component of the value
  31108. * @param z defines the 3rd component of the value
  31109. * @param w defines the 4th component of the value
  31110. */
  31111. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31112. /**
  31113. * Sets a Color4 on a uniform variable
  31114. * @param uniform defines the uniform location
  31115. * @param color4 defines the value to be set
  31116. */
  31117. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31118. /**
  31119. * Set various states to the webGL context
  31120. * @param culling defines backface culling state
  31121. * @param zOffset defines the value to apply to zOffset (0 by default)
  31122. * @param force defines if states must be applied even if cache is up to date
  31123. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31124. */
  31125. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31126. /**
  31127. * Set the z offset to apply to current rendering
  31128. * @param value defines the offset to apply
  31129. */
  31130. setZOffset(value: number): void;
  31131. /**
  31132. * Gets the current value of the zOffset
  31133. * @returns the current zOffset state
  31134. */
  31135. getZOffset(): number;
  31136. /**
  31137. * Enable or disable depth buffering
  31138. * @param enable defines the state to set
  31139. */
  31140. setDepthBuffer(enable: boolean): void;
  31141. /**
  31142. * Gets a boolean indicating if depth writing is enabled
  31143. * @returns the current depth writing state
  31144. */
  31145. getDepthWrite(): boolean;
  31146. /**
  31147. * Enable or disable depth writing
  31148. * @param enable defines the state to set
  31149. */
  31150. setDepthWrite(enable: boolean): void;
  31151. /**
  31152. * Enable or disable color writing
  31153. * @param enable defines the state to set
  31154. */
  31155. setColorWrite(enable: boolean): void;
  31156. /**
  31157. * Gets a boolean indicating if color writing is enabled
  31158. * @returns the current color writing state
  31159. */
  31160. getColorWrite(): boolean;
  31161. /**
  31162. * Sets alpha constants used by some alpha blending modes
  31163. * @param r defines the red component
  31164. * @param g defines the green component
  31165. * @param b defines the blue component
  31166. * @param a defines the alpha component
  31167. */
  31168. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31169. /**
  31170. * Sets the current alpha mode
  31171. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31172. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31173. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31174. */
  31175. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31176. /**
  31177. * Gets the current alpha mode
  31178. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31179. * @returns the current alpha mode
  31180. */
  31181. getAlphaMode(): number;
  31182. /**
  31183. * Clears the list of texture accessible through engine.
  31184. * This can help preventing texture load conflict due to name collision.
  31185. */
  31186. clearInternalTexturesCache(): void;
  31187. /**
  31188. * Force the entire cache to be cleared
  31189. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31190. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31191. */
  31192. wipeCaches(bruteForce?: boolean): void;
  31193. /**
  31194. * Set the compressed texture format to use, based on the formats you have, and the formats
  31195. * supported by the hardware / browser.
  31196. *
  31197. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31198. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31199. * to API arguments needed to compressed textures. This puts the burden on the container
  31200. * generator to house the arcane code for determining these for current & future formats.
  31201. *
  31202. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31203. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31204. *
  31205. * Note: The result of this call is not taken into account when a texture is base64.
  31206. *
  31207. * @param formatsAvailable defines the list of those format families you have created
  31208. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31209. *
  31210. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31211. * @returns The extension selected.
  31212. */
  31213. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31214. /** @hidden */
  31215. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31216. min: number;
  31217. mag: number;
  31218. };
  31219. /** @hidden */
  31220. _createTexture(): WebGLTexture;
  31221. /**
  31222. * Usually called from Texture.ts.
  31223. * Passed information to create a WebGLTexture
  31224. * @param urlArg defines a value which contains one of the following:
  31225. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31226. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31227. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31228. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31229. * @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)
  31230. * @param scene needed for loading to the correct scene
  31231. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31232. * @param onLoad optional callback to be called upon successful completion
  31233. * @param onError optional callback to be called upon failure
  31234. * @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
  31235. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31236. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31237. * @param forcedExtension defines the extension to use to pick the right loader
  31238. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31239. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31240. */
  31241. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31242. /**
  31243. * @hidden
  31244. * Rescales a texture
  31245. * @param source input texutre
  31246. * @param destination destination texture
  31247. * @param scene scene to use to render the resize
  31248. * @param internalFormat format to use when resizing
  31249. * @param onComplete callback to be called when resize has completed
  31250. */
  31251. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31252. private _unpackFlipYCached;
  31253. /**
  31254. * In case you are sharing the context with other applications, it might
  31255. * be interested to not cache the unpack flip y state to ensure a consistent
  31256. * value would be set.
  31257. */
  31258. enableUnpackFlipYCached: boolean;
  31259. /** @hidden */
  31260. _unpackFlipY(value: boolean): void;
  31261. /** @hidden */
  31262. _getUnpackAlignement(): number;
  31263. /**
  31264. * Creates a dynamic texture
  31265. * @param width defines the width of the texture
  31266. * @param height defines the height of the texture
  31267. * @param generateMipMaps defines if the engine should generate the mip levels
  31268. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31269. * @returns the dynamic texture inside an InternalTexture
  31270. */
  31271. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31272. /**
  31273. * Update the sampling mode of a given texture
  31274. * @param samplingMode defines the required sampling mode
  31275. * @param texture defines the texture to update
  31276. */
  31277. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31278. /**
  31279. * Update the content of a dynamic texture
  31280. * @param texture defines the texture to update
  31281. * @param canvas defines the canvas containing the source
  31282. * @param invertY defines if data must be stored with Y axis inverted
  31283. * @param premulAlpha defines if alpha is stored as premultiplied
  31284. * @param format defines the format of the data
  31285. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31286. */
  31287. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31288. /**
  31289. * Update a video texture
  31290. * @param texture defines the texture to update
  31291. * @param video defines the video element to use
  31292. * @param invertY defines if data must be stored with Y axis inverted
  31293. */
  31294. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31295. /**
  31296. * Updates a depth texture Comparison Mode and Function.
  31297. * If the comparison Function is equal to 0, the mode will be set to none.
  31298. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31299. * @param texture The texture to set the comparison function for
  31300. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31301. */
  31302. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31303. /** @hidden */
  31304. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31305. width: number;
  31306. height: number;
  31307. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31308. /**
  31309. * Creates a depth stencil texture.
  31310. * This is only available in WebGL 2 or with the depth texture extension available.
  31311. * @param size The size of face edge in the texture.
  31312. * @param options The options defining the texture.
  31313. * @returns The texture
  31314. */
  31315. createDepthStencilTexture(size: number | {
  31316. width: number;
  31317. height: number;
  31318. }, options: DepthTextureCreationOptions): InternalTexture;
  31319. /**
  31320. * Creates a depth stencil texture.
  31321. * This is only available in WebGL 2 or with the depth texture extension available.
  31322. * @param size The size of face edge in the texture.
  31323. * @param options The options defining the texture.
  31324. * @returns The texture
  31325. */
  31326. private _createDepthStencilTexture;
  31327. /**
  31328. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31329. * @param renderTarget The render target to set the frame buffer for
  31330. */
  31331. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31332. /**
  31333. * Creates a new render target texture
  31334. * @param size defines the size of the texture
  31335. * @param options defines the options used to create the texture
  31336. * @returns a new render target texture stored in an InternalTexture
  31337. */
  31338. createRenderTargetTexture(size: number | {
  31339. width: number;
  31340. height: number;
  31341. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31342. /** @hidden */
  31343. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31344. /**
  31345. * Updates the sample count of a render target texture
  31346. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31347. * @param texture defines the texture to update
  31348. * @param samples defines the sample count to set
  31349. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31350. */
  31351. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31352. /** @hidden */
  31353. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31354. /** @hidden */
  31355. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31356. /** @hidden */
  31357. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31358. /** @hidden */
  31359. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31360. /**
  31361. * @hidden
  31362. */
  31363. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31364. private _prepareWebGLTextureContinuation;
  31365. private _prepareWebGLTexture;
  31366. /** @hidden */
  31367. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31368. /** @hidden */
  31369. _releaseFramebufferObjects(texture: InternalTexture): void;
  31370. /** @hidden */
  31371. _releaseTexture(texture: InternalTexture): void;
  31372. private setProgram;
  31373. private _boundUniforms;
  31374. /**
  31375. * Binds an effect to the webGL context
  31376. * @param effect defines the effect to bind
  31377. */
  31378. bindSamplers(effect: Effect): void;
  31379. private _activateCurrentTexture;
  31380. /** @hidden */
  31381. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31382. /** @hidden */
  31383. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31384. /**
  31385. * Sets a texture to the webGL context from a postprocess
  31386. * @param channel defines the channel to use
  31387. * @param postProcess defines the source postprocess
  31388. */
  31389. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31390. /**
  31391. * Binds the output of the passed in post process to the texture channel specified
  31392. * @param channel The channel the texture should be bound to
  31393. * @param postProcess The post process which's output should be bound
  31394. */
  31395. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31396. /**
  31397. * Unbind all textures from the webGL context
  31398. */
  31399. unbindAllTextures(): void;
  31400. /**
  31401. * Sets a texture to the according uniform.
  31402. * @param channel The texture channel
  31403. * @param uniform The uniform to set
  31404. * @param texture The texture to apply
  31405. */
  31406. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31407. /**
  31408. * Sets a depth stencil texture from a render target to the according uniform.
  31409. * @param channel The texture channel
  31410. * @param uniform The uniform to set
  31411. * @param texture The render target texture containing the depth stencil texture to apply
  31412. */
  31413. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31414. private _bindSamplerUniformToChannel;
  31415. private _getTextureWrapMode;
  31416. private _setTexture;
  31417. /**
  31418. * Sets an array of texture to the webGL context
  31419. * @param channel defines the channel where the texture array must be set
  31420. * @param uniform defines the associated uniform location
  31421. * @param textures defines the array of textures to bind
  31422. */
  31423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31424. /** @hidden */
  31425. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31426. private _setTextureParameterFloat;
  31427. private _setTextureParameterInteger;
  31428. /**
  31429. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31430. * @param x defines the x coordinate of the rectangle where pixels must be read
  31431. * @param y defines the y coordinate of the rectangle where pixels must be read
  31432. * @param width defines the width of the rectangle where pixels must be read
  31433. * @param height defines the height of the rectangle where pixels must be read
  31434. * @returns a Uint8Array containing RGBA colors
  31435. */
  31436. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31437. /**
  31438. * Add an externaly attached data from its key.
  31439. * This method call will fail and return false, if such key already exists.
  31440. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31441. * @param key the unique key that identifies the data
  31442. * @param data the data object to associate to the key for this Engine instance
  31443. * @return true if no such key were already present and the data was added successfully, false otherwise
  31444. */
  31445. addExternalData<T>(key: string, data: T): boolean;
  31446. /**
  31447. * Get an externaly attached data from its key
  31448. * @param key the unique key that identifies the data
  31449. * @return the associated data, if present (can be null), or undefined if not present
  31450. */
  31451. getExternalData<T>(key: string): T;
  31452. /**
  31453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31454. * @param key the unique key that identifies the data
  31455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31456. * @return the associated data, can be null if the factory returned null.
  31457. */
  31458. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31459. /**
  31460. * Remove an externaly attached data from the Engine instance
  31461. * @param key the unique key that identifies the data
  31462. * @return true if the data was successfully removed, false if it doesn't exist
  31463. */
  31464. removeExternalData(key: string): boolean;
  31465. /**
  31466. * Unbind all vertex attributes from the webGL context
  31467. */
  31468. unbindAllAttributes(): void;
  31469. /**
  31470. * 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
  31471. */
  31472. releaseEffects(): void;
  31473. /**
  31474. * Dispose and release all associated resources
  31475. */
  31476. dispose(): void;
  31477. /**
  31478. * Display the loading screen
  31479. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31480. */
  31481. displayLoadingUI(): void;
  31482. /**
  31483. * Hide the loading screen
  31484. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31485. */
  31486. hideLoadingUI(): void;
  31487. /**
  31488. * Gets the current loading screen object
  31489. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31490. */
  31491. /**
  31492. * Sets the current loading screen object
  31493. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31494. */
  31495. loadingScreen: ILoadingScreen;
  31496. /**
  31497. * Sets the current loading screen text
  31498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31499. */
  31500. loadingUIText: string;
  31501. /**
  31502. * Sets the current loading screen background color
  31503. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31504. */
  31505. loadingUIBackgroundColor: string;
  31506. /**
  31507. * Attach a new callback raised when context lost event is fired
  31508. * @param callback defines the callback to call
  31509. */
  31510. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31511. /**
  31512. * Attach a new callback raised when context restored event is fired
  31513. * @param callback defines the callback to call
  31514. */
  31515. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31516. /**
  31517. * Gets the source code of the vertex shader associated with a specific webGL program
  31518. * @param program defines the program to use
  31519. * @returns a string containing the source code of the vertex shader associated with the program
  31520. */
  31521. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31522. /**
  31523. * Gets the source code of the fragment shader associated with a specific webGL program
  31524. * @param program defines the program to use
  31525. * @returns a string containing the source code of the fragment shader associated with the program
  31526. */
  31527. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31528. /**
  31529. * Get the current error code of the webGL context
  31530. * @returns the error code
  31531. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31532. */
  31533. getError(): number;
  31534. /**
  31535. * Gets the current framerate
  31536. * @returns a number representing the framerate
  31537. */
  31538. getFps(): number;
  31539. /**
  31540. * Gets the time spent between current and previous frame
  31541. * @returns a number representing the delta time in ms
  31542. */
  31543. getDeltaTime(): number;
  31544. private _measureFps;
  31545. /** @hidden */
  31546. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31547. private _canRenderToFloatFramebuffer;
  31548. private _canRenderToHalfFloatFramebuffer;
  31549. private _canRenderToFramebuffer;
  31550. /** @hidden */
  31551. _getWebGLTextureType(type: number): number;
  31552. /** @hidden */
  31553. _getInternalFormat(format: number): number;
  31554. /** @hidden */
  31555. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31556. /** @hidden */
  31557. _getRGBAMultiSampleBufferFormat(type: number): number;
  31558. /** @hidden */
  31559. _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;
  31560. /** @hidden */
  31561. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31562. /**
  31563. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31564. * @returns true if the engine can be created
  31565. * @ignorenaming
  31566. */
  31567. static isSupported(): boolean;
  31568. /**
  31569. * Find the next highest power of two.
  31570. * @param x Number to start search from.
  31571. * @return Next highest power of two.
  31572. */
  31573. static CeilingPOT(x: number): number;
  31574. /**
  31575. * Find the next lowest power of two.
  31576. * @param x Number to start search from.
  31577. * @return Next lowest power of two.
  31578. */
  31579. static FloorPOT(x: number): number;
  31580. /**
  31581. * Find the nearest power of two.
  31582. * @param x Number to start search from.
  31583. * @return Next nearest power of two.
  31584. */
  31585. static NearestPOT(x: number): number;
  31586. /**
  31587. * Get the closest exponent of two
  31588. * @param value defines the value to approximate
  31589. * @param max defines the maximum value to return
  31590. * @param mode defines how to define the closest value
  31591. * @returns closest exponent of two of the given value
  31592. */
  31593. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31594. /**
  31595. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31596. * @param func - the function to be called
  31597. * @param requester - the object that will request the next frame. Falls back to window.
  31598. * @returns frame number
  31599. */
  31600. static QueueNewFrame(func: () => void, requester?: any): number;
  31601. /**
  31602. * Ask the browser to promote the current element to pointerlock mode
  31603. * @param element defines the DOM element to promote
  31604. */
  31605. static _RequestPointerlock(element: HTMLElement): void;
  31606. /**
  31607. * Asks the browser to exit pointerlock mode
  31608. */
  31609. static _ExitPointerlock(): void;
  31610. /**
  31611. * Ask the browser to promote the current element to fullscreen rendering mode
  31612. * @param element defines the DOM element to promote
  31613. */
  31614. static _RequestFullscreen(element: HTMLElement): void;
  31615. /**
  31616. * Asks the browser to exit fullscreen mode
  31617. */
  31618. static _ExitFullscreen(): void;
  31619. }
  31620. }
  31621. declare module BABYLON {
  31622. /**
  31623. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31624. * during the life time of the application.
  31625. */
  31626. export class EngineStore {
  31627. /** Gets the list of created engines */
  31628. static Instances: Engine[];
  31629. /** @hidden */
  31630. static _LastCreatedScene: Nullable<Scene>;
  31631. /**
  31632. * Gets the latest created engine
  31633. */
  31634. static readonly LastCreatedEngine: Nullable<Engine>;
  31635. /**
  31636. * Gets the latest created scene
  31637. */
  31638. static readonly LastCreatedScene: Nullable<Scene>;
  31639. /**
  31640. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31641. * @ignorenaming
  31642. */
  31643. static UseFallbackTexture: boolean;
  31644. /**
  31645. * Texture content used if a texture cannot loaded
  31646. * @ignorenaming
  31647. */
  31648. static FallbackTexture: string;
  31649. }
  31650. }
  31651. declare module BABYLON {
  31652. /**
  31653. * Helper class that provides a small promise polyfill
  31654. */
  31655. export class PromisePolyfill {
  31656. /**
  31657. * Static function used to check if the polyfill is required
  31658. * If this is the case then the function will inject the polyfill to window.Promise
  31659. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31660. */
  31661. static Apply(force?: boolean): void;
  31662. }
  31663. }
  31664. declare module BABYLON {
  31665. /**
  31666. * Interface for screenshot methods with describe argument called `size` as object with options
  31667. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31668. */
  31669. export interface IScreenshotSize {
  31670. /**
  31671. * number in pixels for canvas height
  31672. */
  31673. height?: number;
  31674. /**
  31675. * multiplier allowing render at a higher or lower resolution
  31676. * If value is defined then height and width will be ignored and taken from camera
  31677. */
  31678. precision?: number;
  31679. /**
  31680. * number in pixels for canvas width
  31681. */
  31682. width?: number;
  31683. }
  31684. }
  31685. declare module BABYLON {
  31686. interface IColor4Like {
  31687. r: float;
  31688. g: float;
  31689. b: float;
  31690. a: float;
  31691. }
  31692. /**
  31693. * Class containing a set of static utilities functions
  31694. */
  31695. export class Tools {
  31696. /**
  31697. * Gets or sets the base URL to use to load assets
  31698. */
  31699. static BaseUrl: string;
  31700. /**
  31701. * Enable/Disable Custom HTTP Request Headers globally.
  31702. * default = false
  31703. * @see CustomRequestHeaders
  31704. */
  31705. static UseCustomRequestHeaders: boolean;
  31706. /**
  31707. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31708. * i.e. when loading files, where the server/service expects an Authorization header
  31709. */
  31710. static CustomRequestHeaders: {
  31711. [key: string]: string;
  31712. };
  31713. /**
  31714. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31715. */
  31716. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31717. /**
  31718. * Default behaviour for cors in the application.
  31719. * It can be a string if the expected behavior is identical in the entire app.
  31720. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31721. */
  31722. static CorsBehavior: string | ((url: string | string[]) => string);
  31723. /**
  31724. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31725. * @ignorenaming
  31726. */
  31727. static UseFallbackTexture: boolean;
  31728. /**
  31729. * Use this object to register external classes like custom textures or material
  31730. * to allow the laoders to instantiate them
  31731. */
  31732. static RegisteredExternalClasses: {
  31733. [key: string]: Object;
  31734. };
  31735. /**
  31736. * Texture content used if a texture cannot loaded
  31737. * @ignorenaming
  31738. */
  31739. static fallbackTexture: string;
  31740. /**
  31741. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31742. * @param u defines the coordinate on X axis
  31743. * @param v defines the coordinate on Y axis
  31744. * @param width defines the width of the source data
  31745. * @param height defines the height of the source data
  31746. * @param pixels defines the source byte array
  31747. * @param color defines the output color
  31748. */
  31749. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31750. /**
  31751. * Interpolates between a and b via alpha
  31752. * @param a The lower value (returned when alpha = 0)
  31753. * @param b The upper value (returned when alpha = 1)
  31754. * @param alpha The interpolation-factor
  31755. * @return The mixed value
  31756. */
  31757. static Mix(a: number, b: number, alpha: number): number;
  31758. /**
  31759. * Tries to instantiate a new object from a given class name
  31760. * @param className defines the class name to instantiate
  31761. * @returns the new object or null if the system was not able to do the instantiation
  31762. */
  31763. static Instantiate(className: string): any;
  31764. /**
  31765. * Provides a slice function that will work even on IE
  31766. * @param data defines the array to slice
  31767. * @param start defines the start of the data (optional)
  31768. * @param end defines the end of the data (optional)
  31769. * @returns the new sliced array
  31770. */
  31771. static Slice<T>(data: T, start?: number, end?: number): T;
  31772. /**
  31773. * Polyfill for setImmediate
  31774. * @param action defines the action to execute after the current execution block
  31775. */
  31776. static SetImmediate(action: () => void): void;
  31777. /**
  31778. * Function indicating if a number is an exponent of 2
  31779. * @param value defines the value to test
  31780. * @returns true if the value is an exponent of 2
  31781. */
  31782. static IsExponentOfTwo(value: number): boolean;
  31783. private static _tmpFloatArray;
  31784. /**
  31785. * Returns the nearest 32-bit single precision float representation of a Number
  31786. * @param value A Number. If the parameter is of a different type, it will get converted
  31787. * to a number or to NaN if it cannot be converted
  31788. * @returns number
  31789. */
  31790. static FloatRound(value: number): number;
  31791. /**
  31792. * Extracts the filename from a path
  31793. * @param path defines the path to use
  31794. * @returns the filename
  31795. */
  31796. static GetFilename(path: string): string;
  31797. /**
  31798. * Extracts the "folder" part of a path (everything before the filename).
  31799. * @param uri The URI to extract the info from
  31800. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31801. * @returns The "folder" part of the path
  31802. */
  31803. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31804. /**
  31805. * Extracts text content from a DOM element hierarchy
  31806. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31807. */
  31808. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31809. /**
  31810. * Convert an angle in radians to degrees
  31811. * @param angle defines the angle to convert
  31812. * @returns the angle in degrees
  31813. */
  31814. static ToDegrees(angle: number): number;
  31815. /**
  31816. * Convert an angle in degrees to radians
  31817. * @param angle defines the angle to convert
  31818. * @returns the angle in radians
  31819. */
  31820. static ToRadians(angle: number): number;
  31821. /**
  31822. * Encode a buffer to a base64 string
  31823. * @param buffer defines the buffer to encode
  31824. * @returns the encoded string
  31825. */
  31826. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31827. /**
  31828. * Returns an array if obj is not an array
  31829. * @param obj defines the object to evaluate as an array
  31830. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31831. * @returns either obj directly if obj is an array or a new array containing obj
  31832. */
  31833. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31834. /**
  31835. * Gets the pointer prefix to use
  31836. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31837. */
  31838. static GetPointerPrefix(): string;
  31839. /**
  31840. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31841. * @param url define the url we are trying
  31842. * @param element define the dom element where to configure the cors policy
  31843. */
  31844. static SetCorsBehavior(url: string | string[], element: {
  31845. crossOrigin: string | null;
  31846. }): void;
  31847. /**
  31848. * Removes unwanted characters from an url
  31849. * @param url defines the url to clean
  31850. * @returns the cleaned url
  31851. */
  31852. static CleanUrl(url: string): string;
  31853. /**
  31854. * Gets or sets a function used to pre-process url before using them to load assets
  31855. */
  31856. static PreprocessUrl: (url: string) => string;
  31857. /**
  31858. * Loads an image as an HTMLImageElement.
  31859. * @param input url string, ArrayBuffer, or Blob to load
  31860. * @param onLoad callback called when the image successfully loads
  31861. * @param onError callback called when the image fails to load
  31862. * @param offlineProvider offline provider for caching
  31863. * @returns the HTMLImageElement of the loaded image
  31864. */
  31865. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31866. /**
  31867. * Loads a file
  31868. * @param url url string, ArrayBuffer, or Blob to load
  31869. * @param onSuccess callback called when the file successfully loads
  31870. * @param onProgress callback called while file is loading (if the server supports this mode)
  31871. * @param offlineProvider defines the offline provider for caching
  31872. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31873. * @param onError callback called when the file fails to load
  31874. * @returns a file request object
  31875. */
  31876. 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;
  31877. /**
  31878. * Loads a file from a url
  31879. * @param url the file url to load
  31880. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31881. */
  31882. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31883. /**
  31884. * Load a script (identified by an url). When the url returns, the
  31885. * content of this file is added into a new script element, attached to the DOM (body element)
  31886. * @param scriptUrl defines the url of the script to laod
  31887. * @param onSuccess defines the callback called when the script is loaded
  31888. * @param onError defines the callback to call if an error occurs
  31889. * @param scriptId defines the id of the script element
  31890. */
  31891. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31892. /**
  31893. * Load an asynchronous script (identified by an url). When the url returns, the
  31894. * content of this file is added into a new script element, attached to the DOM (body element)
  31895. * @param scriptUrl defines the url of the script to laod
  31896. * @param scriptId defines the id of the script element
  31897. * @returns a promise request object
  31898. */
  31899. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31900. /**
  31901. * Loads a file from a blob
  31902. * @param fileToLoad defines the blob to use
  31903. * @param callback defines the callback to call when data is loaded
  31904. * @param progressCallback defines the callback to call during loading process
  31905. * @returns a file request object
  31906. */
  31907. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31908. /**
  31909. * Loads a file
  31910. * @param fileToLoad defines the file to load
  31911. * @param callback defines the callback to call when data is loaded
  31912. * @param progressCallBack defines the callback to call during loading process
  31913. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31914. * @returns a file request object
  31915. */
  31916. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31917. /**
  31918. * Creates a data url from a given string content
  31919. * @param content defines the content to convert
  31920. * @returns the new data url link
  31921. */
  31922. static FileAsURL(content: string): string;
  31923. /**
  31924. * Format the given number to a specific decimal format
  31925. * @param value defines the number to format
  31926. * @param decimals defines the number of decimals to use
  31927. * @returns the formatted string
  31928. */
  31929. static Format(value: number, decimals?: number): string;
  31930. /**
  31931. * Tries to copy an object by duplicating every property
  31932. * @param source defines the source object
  31933. * @param destination defines the target object
  31934. * @param doNotCopyList defines a list of properties to avoid
  31935. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31936. */
  31937. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31938. /**
  31939. * Gets a boolean indicating if the given object has no own property
  31940. * @param obj defines the object to test
  31941. * @returns true if object has no own property
  31942. */
  31943. static IsEmpty(obj: any): boolean;
  31944. /**
  31945. * Function used to register events at window level
  31946. * @param windowElement defines the Window object to use
  31947. * @param events defines the events to register
  31948. */
  31949. static RegisterTopRootEvents(windowElement: Window, events: {
  31950. name: string;
  31951. handler: Nullable<(e: FocusEvent) => any>;
  31952. }[]): void;
  31953. /**
  31954. * Function used to unregister events from window level
  31955. * @param windowElement defines the Window object to use
  31956. * @param events defines the events to unregister
  31957. */
  31958. static UnregisterTopRootEvents(windowElement: Window, events: {
  31959. name: string;
  31960. handler: Nullable<(e: FocusEvent) => any>;
  31961. }[]): void;
  31962. /**
  31963. * @ignore
  31964. */
  31965. static _ScreenshotCanvas: HTMLCanvasElement;
  31966. /**
  31967. * Dumps the current bound framebuffer
  31968. * @param width defines the rendering width
  31969. * @param height defines the rendering height
  31970. * @param engine defines the hosting engine
  31971. * @param successCallback defines the callback triggered once the data are available
  31972. * @param mimeType defines the mime type of the result
  31973. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31974. */
  31975. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31976. /**
  31977. * Converts the canvas data to blob.
  31978. * This acts as a polyfill for browsers not supporting the to blob function.
  31979. * @param canvas Defines the canvas to extract the data from
  31980. * @param successCallback Defines the callback triggered once the data are available
  31981. * @param mimeType Defines the mime type of the result
  31982. */
  31983. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31984. /**
  31985. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31986. * @param successCallback defines the callback triggered once the data are available
  31987. * @param mimeType defines the mime type of the result
  31988. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31989. */
  31990. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31991. /**
  31992. * Downloads a blob in the browser
  31993. * @param blob defines the blob to download
  31994. * @param fileName defines the name of the downloaded file
  31995. */
  31996. static Download(blob: Blob, fileName: string): void;
  31997. /**
  31998. * Captures a screenshot of the current rendering
  31999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32000. * @param engine defines the rendering engine
  32001. * @param camera defines the source camera
  32002. * @param size This parameter can be set to a single number or to an object with the
  32003. * following (optional) properties: precision, width, height. If a single number is passed,
  32004. * it will be used for both width and height. If an object is passed, the screenshot size
  32005. * will be derived from the parameters. The precision property is a multiplier allowing
  32006. * rendering at a higher or lower resolution
  32007. * @param successCallback defines the callback receives a single parameter which contains the
  32008. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32009. * src parameter of an <img> to display it
  32010. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32011. * Check your browser for supported MIME types
  32012. */
  32013. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32014. /**
  32015. * Captures a screenshot of the current rendering
  32016. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32017. * @param engine defines the rendering engine
  32018. * @param camera defines the source camera
  32019. * @param size This parameter can be set to a single number or to an object with the
  32020. * following (optional) properties: precision, width, height. If a single number is passed,
  32021. * it will be used for both width and height. If an object is passed, the screenshot size
  32022. * will be derived from the parameters. The precision property is a multiplier allowing
  32023. * rendering at a higher or lower resolution
  32024. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32025. * Check your browser for supported MIME types
  32026. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32027. * to the src parameter of an <img> to display it
  32028. */
  32029. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32030. /**
  32031. * Generates an image screenshot from the specified camera.
  32032. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32033. * @param engine The engine to use for rendering
  32034. * @param camera The camera to use for rendering
  32035. * @param size This parameter can be set to a single number or to an object with the
  32036. * following (optional) properties: precision, width, height. If a single number is passed,
  32037. * it will be used for both width and height. If an object is passed, the screenshot size
  32038. * will be derived from the parameters. The precision property is a multiplier allowing
  32039. * rendering at a higher or lower resolution
  32040. * @param successCallback The callback receives a single parameter which contains the
  32041. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32042. * src parameter of an <img> to display it
  32043. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32044. * Check your browser for supported MIME types
  32045. * @param samples Texture samples (default: 1)
  32046. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32047. * @param fileName A name for for the downloaded file.
  32048. */
  32049. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32050. /**
  32051. * Generates an image screenshot from the specified camera.
  32052. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32053. * @param engine The engine to use for rendering
  32054. * @param camera The camera to use for rendering
  32055. * @param size This parameter can be set to a single number or to an object with the
  32056. * following (optional) properties: precision, width, height. If a single number is passed,
  32057. * it will be used for both width and height. If an object is passed, the screenshot size
  32058. * will be derived from the parameters. The precision property is a multiplier allowing
  32059. * rendering at a higher or lower resolution
  32060. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32061. * Check your browser for supported MIME types
  32062. * @param samples Texture samples (default: 1)
  32063. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32064. * @param fileName A name for for the downloaded file.
  32065. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32066. * to the src parameter of an <img> to display it
  32067. */
  32068. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32069. /**
  32070. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32071. * Be aware Math.random() could cause collisions, but:
  32072. * "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"
  32073. * @returns a pseudo random id
  32074. */
  32075. static RandomId(): string;
  32076. /**
  32077. * Test if the given uri is a base64 string
  32078. * @param uri The uri to test
  32079. * @return True if the uri is a base64 string or false otherwise
  32080. */
  32081. static IsBase64(uri: string): boolean;
  32082. /**
  32083. * Decode the given base64 uri.
  32084. * @param uri The uri to decode
  32085. * @return The decoded base64 data.
  32086. */
  32087. static DecodeBase64(uri: string): ArrayBuffer;
  32088. /**
  32089. * Gets the absolute url.
  32090. * @param url the input url
  32091. * @return the absolute url
  32092. */
  32093. static GetAbsoluteUrl(url: string): string;
  32094. /**
  32095. * No log
  32096. */
  32097. static readonly NoneLogLevel: number;
  32098. /**
  32099. * Only message logs
  32100. */
  32101. static readonly MessageLogLevel: number;
  32102. /**
  32103. * Only warning logs
  32104. */
  32105. static readonly WarningLogLevel: number;
  32106. /**
  32107. * Only error logs
  32108. */
  32109. static readonly ErrorLogLevel: number;
  32110. /**
  32111. * All logs
  32112. */
  32113. static readonly AllLogLevel: number;
  32114. /**
  32115. * Gets a value indicating the number of loading errors
  32116. * @ignorenaming
  32117. */
  32118. static readonly errorsCount: number;
  32119. /**
  32120. * Callback called when a new log is added
  32121. */
  32122. static OnNewCacheEntry: (entry: string) => void;
  32123. /**
  32124. * Log a message to the console
  32125. * @param message defines the message to log
  32126. */
  32127. static Log(message: string): void;
  32128. /**
  32129. * Write a warning message to the console
  32130. * @param message defines the message to log
  32131. */
  32132. static Warn(message: string): void;
  32133. /**
  32134. * Write an error message to the console
  32135. * @param message defines the message to log
  32136. */
  32137. static Error(message: string): void;
  32138. /**
  32139. * Gets current log cache (list of logs)
  32140. */
  32141. static readonly LogCache: string;
  32142. /**
  32143. * Clears the log cache
  32144. */
  32145. static ClearLogCache(): void;
  32146. /**
  32147. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32148. */
  32149. static LogLevels: number;
  32150. /**
  32151. * Checks if the window object exists
  32152. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32153. */
  32154. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32155. /**
  32156. * No performance log
  32157. */
  32158. static readonly PerformanceNoneLogLevel: number;
  32159. /**
  32160. * Use user marks to log performance
  32161. */
  32162. static readonly PerformanceUserMarkLogLevel: number;
  32163. /**
  32164. * Log performance to the console
  32165. */
  32166. static readonly PerformanceConsoleLogLevel: number;
  32167. private static _performance;
  32168. /**
  32169. * Sets the current performance log level
  32170. */
  32171. static PerformanceLogLevel: number;
  32172. private static _StartPerformanceCounterDisabled;
  32173. private static _EndPerformanceCounterDisabled;
  32174. private static _StartUserMark;
  32175. private static _EndUserMark;
  32176. private static _StartPerformanceConsole;
  32177. private static _EndPerformanceConsole;
  32178. /**
  32179. * Starts a performance counter
  32180. */
  32181. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32182. /**
  32183. * Ends a specific performance coutner
  32184. */
  32185. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32186. /**
  32187. * Gets either window.performance.now() if supported or Date.now() else
  32188. */
  32189. static readonly Now: number;
  32190. /**
  32191. * This method will return the name of the class used to create the instance of the given object.
  32192. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32193. * @param object the object to get the class name from
  32194. * @param isType defines if the object is actually a type
  32195. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32196. */
  32197. static GetClassName(object: any, isType?: boolean): string;
  32198. /**
  32199. * Gets the first element of an array satisfying a given predicate
  32200. * @param array defines the array to browse
  32201. * @param predicate defines the predicate to use
  32202. * @returns null if not found or the element
  32203. */
  32204. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32205. /**
  32206. * This method will return the name of the full name of the class, including its owning module (if any).
  32207. * 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).
  32208. * @param object the object to get the class name from
  32209. * @param isType defines if the object is actually a type
  32210. * @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.
  32211. * @ignorenaming
  32212. */
  32213. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32214. /**
  32215. * Returns a promise that resolves after the given amount of time.
  32216. * @param delay Number of milliseconds to delay
  32217. * @returns Promise that resolves after the given amount of time
  32218. */
  32219. static DelayAsync(delay: number): Promise<void>;
  32220. }
  32221. /**
  32222. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32223. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32224. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32225. * @param name The name of the class, case should be preserved
  32226. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32227. */
  32228. export function className(name: string, module?: string): (target: Object) => void;
  32229. /**
  32230. * An implementation of a loop for asynchronous functions.
  32231. */
  32232. export class AsyncLoop {
  32233. /**
  32234. * Defines the number of iterations for the loop
  32235. */
  32236. iterations: number;
  32237. /**
  32238. * Defines the current index of the loop.
  32239. */
  32240. index: number;
  32241. private _done;
  32242. private _fn;
  32243. private _successCallback;
  32244. /**
  32245. * Constructor.
  32246. * @param iterations the number of iterations.
  32247. * @param func the function to run each iteration
  32248. * @param successCallback the callback that will be called upon succesful execution
  32249. * @param offset starting offset.
  32250. */
  32251. constructor(
  32252. /**
  32253. * Defines the number of iterations for the loop
  32254. */
  32255. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32256. /**
  32257. * Execute the next iteration. Must be called after the last iteration was finished.
  32258. */
  32259. executeNext(): void;
  32260. /**
  32261. * Break the loop and run the success callback.
  32262. */
  32263. breakLoop(): void;
  32264. /**
  32265. * Create and run an async loop.
  32266. * @param iterations the number of iterations.
  32267. * @param fn the function to run each iteration
  32268. * @param successCallback the callback that will be called upon succesful execution
  32269. * @param offset starting offset.
  32270. * @returns the created async loop object
  32271. */
  32272. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32273. /**
  32274. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32275. * @param iterations total number of iterations
  32276. * @param syncedIterations number of synchronous iterations in each async iteration.
  32277. * @param fn the function to call each iteration.
  32278. * @param callback a success call back that will be called when iterating stops.
  32279. * @param breakFunction a break condition (optional)
  32280. * @param timeout timeout settings for the setTimeout function. default - 0.
  32281. * @returns the created async loop object
  32282. */
  32283. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32284. }
  32285. }
  32286. declare module BABYLON {
  32287. /** @hidden */
  32288. export interface ICollisionCoordinator {
  32289. createCollider(): Collider;
  32290. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32291. init(scene: Scene): void;
  32292. }
  32293. /** @hidden */
  32294. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32295. private _scene;
  32296. private _scaledPosition;
  32297. private _scaledVelocity;
  32298. private _finalPosition;
  32299. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32300. createCollider(): Collider;
  32301. init(scene: Scene): void;
  32302. private _collideWithWorld;
  32303. }
  32304. }
  32305. declare module BABYLON {
  32306. /**
  32307. * Class used to manage all inputs for the scene.
  32308. */
  32309. export class InputManager {
  32310. /** The distance in pixel that you have to move to prevent some events */
  32311. static DragMovementThreshold: number;
  32312. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32313. static LongPressDelay: number;
  32314. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32315. static DoubleClickDelay: number;
  32316. /** If you need to check double click without raising a single click at first click, enable this flag */
  32317. static ExclusiveDoubleClickMode: boolean;
  32318. private _wheelEventName;
  32319. private _onPointerMove;
  32320. private _onPointerDown;
  32321. private _onPointerUp;
  32322. private _initClickEvent;
  32323. private _initActionManager;
  32324. private _delayedSimpleClick;
  32325. private _delayedSimpleClickTimeout;
  32326. private _previousDelayedSimpleClickTimeout;
  32327. private _meshPickProceed;
  32328. private _previousButtonPressed;
  32329. private _currentPickResult;
  32330. private _previousPickResult;
  32331. private _totalPointersPressed;
  32332. private _doubleClickOccured;
  32333. private _pointerOverMesh;
  32334. private _pickedDownMesh;
  32335. private _pickedUpMesh;
  32336. private _pointerX;
  32337. private _pointerY;
  32338. private _unTranslatedPointerX;
  32339. private _unTranslatedPointerY;
  32340. private _startingPointerPosition;
  32341. private _previousStartingPointerPosition;
  32342. private _startingPointerTime;
  32343. private _previousStartingPointerTime;
  32344. private _pointerCaptures;
  32345. private _onKeyDown;
  32346. private _onKeyUp;
  32347. private _onCanvasFocusObserver;
  32348. private _onCanvasBlurObserver;
  32349. private _scene;
  32350. /**
  32351. * Creates a new InputManager
  32352. * @param scene defines the hosting scene
  32353. */
  32354. constructor(scene: Scene);
  32355. /**
  32356. * Gets the mesh that is currently under the pointer
  32357. */
  32358. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32359. /**
  32360. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32361. */
  32362. readonly unTranslatedPointer: Vector2;
  32363. /**
  32364. * Gets or sets the current on-screen X position of the pointer
  32365. */
  32366. pointerX: number;
  32367. /**
  32368. * Gets or sets the current on-screen Y position of the pointer
  32369. */
  32370. pointerY: number;
  32371. private _updatePointerPosition;
  32372. private _processPointerMove;
  32373. private _setRayOnPointerInfo;
  32374. private _checkPrePointerObservable;
  32375. /**
  32376. * Use this method to simulate a pointer move on a mesh
  32377. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32378. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32379. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32380. */
  32381. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32382. /**
  32383. * Use this method to simulate a pointer down on a mesh
  32384. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32385. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32386. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32387. */
  32388. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32389. private _processPointerDown;
  32390. /** @hidden */
  32391. _isPointerSwiping(): boolean;
  32392. /**
  32393. * Use this method to simulate a pointer up on a mesh
  32394. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32395. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32396. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32397. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32398. */
  32399. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32400. private _processPointerUp;
  32401. /**
  32402. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32403. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32404. * @returns true if the pointer was captured
  32405. */
  32406. isPointerCaptured(pointerId?: number): boolean;
  32407. /**
  32408. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32409. * @param attachUp defines if you want to attach events to pointerup
  32410. * @param attachDown defines if you want to attach events to pointerdown
  32411. * @param attachMove defines if you want to attach events to pointermove
  32412. */
  32413. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32414. /**
  32415. * Detaches all event handlers
  32416. */
  32417. detachControl(): void;
  32418. /**
  32419. * Force the value of meshUnderPointer
  32420. * @param mesh defines the mesh to use
  32421. */
  32422. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32423. /**
  32424. * Gets the mesh under the pointer
  32425. * @returns a Mesh or null if no mesh is under the pointer
  32426. */
  32427. getPointerOverMesh(): Nullable<AbstractMesh>;
  32428. }
  32429. }
  32430. declare module BABYLON {
  32431. /**
  32432. * Helper class used to generate session unique ID
  32433. */
  32434. export class UniqueIdGenerator {
  32435. private static _UniqueIdCounter;
  32436. /**
  32437. * Gets an unique (relatively to the current scene) Id
  32438. */
  32439. static readonly UniqueId: number;
  32440. }
  32441. }
  32442. declare module BABYLON {
  32443. /**
  32444. * This class defines the direct association between an animation and a target
  32445. */
  32446. export class TargetedAnimation {
  32447. /**
  32448. * Animation to perform
  32449. */
  32450. animation: Animation;
  32451. /**
  32452. * Target to animate
  32453. */
  32454. target: any;
  32455. /**
  32456. * Serialize the object
  32457. * @returns the JSON object representing the current entity
  32458. */
  32459. serialize(): any;
  32460. }
  32461. /**
  32462. * Use this class to create coordinated animations on multiple targets
  32463. */
  32464. export class AnimationGroup implements IDisposable {
  32465. /** The name of the animation group */
  32466. name: string;
  32467. private _scene;
  32468. private _targetedAnimations;
  32469. private _animatables;
  32470. private _from;
  32471. private _to;
  32472. private _isStarted;
  32473. private _isPaused;
  32474. private _speedRatio;
  32475. private _loopAnimation;
  32476. /**
  32477. * Gets or sets the unique id of the node
  32478. */
  32479. uniqueId: number;
  32480. /**
  32481. * This observable will notify when one animation have ended
  32482. */
  32483. onAnimationEndObservable: Observable<TargetedAnimation>;
  32484. /**
  32485. * Observer raised when one animation loops
  32486. */
  32487. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32488. /**
  32489. * This observable will notify when all animations have ended.
  32490. */
  32491. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32492. /**
  32493. * This observable will notify when all animations have paused.
  32494. */
  32495. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32496. /**
  32497. * This observable will notify when all animations are playing.
  32498. */
  32499. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32500. /**
  32501. * Gets the first frame
  32502. */
  32503. readonly from: number;
  32504. /**
  32505. * Gets the last frame
  32506. */
  32507. readonly to: number;
  32508. /**
  32509. * Define if the animations are started
  32510. */
  32511. readonly isStarted: boolean;
  32512. /**
  32513. * Gets a value indicating that the current group is playing
  32514. */
  32515. readonly isPlaying: boolean;
  32516. /**
  32517. * Gets or sets the speed ratio to use for all animations
  32518. */
  32519. /**
  32520. * Gets or sets the speed ratio to use for all animations
  32521. */
  32522. speedRatio: number;
  32523. /**
  32524. * Gets or sets if all animations should loop or not
  32525. */
  32526. loopAnimation: boolean;
  32527. /**
  32528. * Gets the targeted animations for this animation group
  32529. */
  32530. readonly targetedAnimations: Array<TargetedAnimation>;
  32531. /**
  32532. * returning the list of animatables controlled by this animation group.
  32533. */
  32534. readonly animatables: Array<Animatable>;
  32535. /**
  32536. * Instantiates a new Animation Group.
  32537. * This helps managing several animations at once.
  32538. * @see http://doc.babylonjs.com/how_to/group
  32539. * @param name Defines the name of the group
  32540. * @param scene Defines the scene the group belongs to
  32541. */
  32542. constructor(
  32543. /** The name of the animation group */
  32544. name: string, scene?: Nullable<Scene>);
  32545. /**
  32546. * Add an animation (with its target) in the group
  32547. * @param animation defines the animation we want to add
  32548. * @param target defines the target of the animation
  32549. * @returns the TargetedAnimation object
  32550. */
  32551. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32552. /**
  32553. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32554. * It can add constant keys at begin or end
  32555. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32556. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32557. * @returns the animation group
  32558. */
  32559. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32560. /**
  32561. * Start all animations on given targets
  32562. * @param loop defines if animations must loop
  32563. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32564. * @param from defines the from key (optional)
  32565. * @param to defines the to key (optional)
  32566. * @returns the current animation group
  32567. */
  32568. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32569. /**
  32570. * Pause all animations
  32571. * @returns the animation group
  32572. */
  32573. pause(): AnimationGroup;
  32574. /**
  32575. * Play all animations to initial state
  32576. * This function will start() the animations if they were not started or will restart() them if they were paused
  32577. * @param loop defines if animations must loop
  32578. * @returns the animation group
  32579. */
  32580. play(loop?: boolean): AnimationGroup;
  32581. /**
  32582. * Reset all animations to initial state
  32583. * @returns the animation group
  32584. */
  32585. reset(): AnimationGroup;
  32586. /**
  32587. * Restart animations from key 0
  32588. * @returns the animation group
  32589. */
  32590. restart(): AnimationGroup;
  32591. /**
  32592. * Stop all animations
  32593. * @returns the animation group
  32594. */
  32595. stop(): AnimationGroup;
  32596. /**
  32597. * Set animation weight for all animatables
  32598. * @param weight defines the weight to use
  32599. * @return the animationGroup
  32600. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32601. */
  32602. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32603. /**
  32604. * Synchronize and normalize all animatables with a source animatable
  32605. * @param root defines the root animatable to synchronize with
  32606. * @return the animationGroup
  32607. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32608. */
  32609. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32610. /**
  32611. * Goes to a specific frame in this animation group
  32612. * @param frame the frame number to go to
  32613. * @return the animationGroup
  32614. */
  32615. goToFrame(frame: number): AnimationGroup;
  32616. /**
  32617. * Dispose all associated resources
  32618. */
  32619. dispose(): void;
  32620. private _checkAnimationGroupEnded;
  32621. /**
  32622. * Clone the current animation group and returns a copy
  32623. * @param newName defines the name of the new group
  32624. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32625. * @returns the new aniamtion group
  32626. */
  32627. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32628. /**
  32629. * Serializes the animationGroup to an object
  32630. * @returns Serialized object
  32631. */
  32632. serialize(): any;
  32633. /**
  32634. * Returns a new AnimationGroup object parsed from the source provided.
  32635. * @param parsedAnimationGroup defines the source
  32636. * @param scene defines the scene that will receive the animationGroup
  32637. * @returns a new AnimationGroup
  32638. */
  32639. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32640. /**
  32641. * Returns the string "AnimationGroup"
  32642. * @returns "AnimationGroup"
  32643. */
  32644. getClassName(): string;
  32645. /**
  32646. * Creates a detailled string about the object
  32647. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32648. * @returns a string representing the object
  32649. */
  32650. toString(fullDetails?: boolean): string;
  32651. }
  32652. }
  32653. declare module BABYLON {
  32654. /**
  32655. * Define an interface for all classes that will hold resources
  32656. */
  32657. export interface IDisposable {
  32658. /**
  32659. * Releases all held resources
  32660. */
  32661. dispose(): void;
  32662. }
  32663. /** Interface defining initialization parameters for Scene class */
  32664. export interface SceneOptions {
  32665. /**
  32666. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32667. * It will improve performance when the number of geometries becomes important.
  32668. */
  32669. useGeometryUniqueIdsMap?: boolean;
  32670. /**
  32671. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32672. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32673. */
  32674. useMaterialMeshMap?: boolean;
  32675. /**
  32676. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32677. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32678. */
  32679. useClonedMeshhMap?: boolean;
  32680. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32681. virtual?: boolean;
  32682. }
  32683. /**
  32684. * Represents a scene to be rendered by the engine.
  32685. * @see http://doc.babylonjs.com/features/scene
  32686. */
  32687. export class Scene extends AbstractScene implements IAnimatable {
  32688. /** The fog is deactivated */
  32689. static readonly FOGMODE_NONE: number;
  32690. /** The fog density is following an exponential function */
  32691. static readonly FOGMODE_EXP: number;
  32692. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32693. static readonly FOGMODE_EXP2: number;
  32694. /** The fog density is following a linear function. */
  32695. static readonly FOGMODE_LINEAR: number;
  32696. /**
  32697. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32699. */
  32700. static MinDeltaTime: number;
  32701. /**
  32702. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32704. */
  32705. static MaxDeltaTime: number;
  32706. /**
  32707. * Factory used to create the default material.
  32708. * @param name The name of the material to create
  32709. * @param scene The scene to create the material for
  32710. * @returns The default material
  32711. */
  32712. static DefaultMaterialFactory(scene: Scene): Material;
  32713. /**
  32714. * Factory used to create the a collision coordinator.
  32715. * @returns The collision coordinator
  32716. */
  32717. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32718. /** @hidden */
  32719. _inputManager: InputManager;
  32720. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32721. cameraToUseForPointers: Nullable<Camera>;
  32722. /** @hidden */
  32723. readonly _isScene: boolean;
  32724. /**
  32725. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32726. */
  32727. autoClear: boolean;
  32728. /**
  32729. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32730. */
  32731. autoClearDepthAndStencil: boolean;
  32732. /**
  32733. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32734. */
  32735. clearColor: Color4;
  32736. /**
  32737. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32738. */
  32739. ambientColor: Color3;
  32740. /**
  32741. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32742. * It should only be one of the following (if not the default embedded one):
  32743. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32744. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32745. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32746. * The material properties need to be setup according to the type of texture in use.
  32747. */
  32748. environmentBRDFTexture: BaseTexture;
  32749. /** @hidden */
  32750. protected _environmentTexture: Nullable<BaseTexture>;
  32751. /**
  32752. * Texture used in all pbr material as the reflection texture.
  32753. * As in the majority of the scene they are the same (exception for multi room and so on),
  32754. * this is easier to reference from here than from all the materials.
  32755. */
  32756. /**
  32757. * Texture used in all pbr material as the reflection texture.
  32758. * As in the majority of the scene they are the same (exception for multi room and so on),
  32759. * this is easier to set here than in all the materials.
  32760. */
  32761. environmentTexture: Nullable<BaseTexture>;
  32762. /** @hidden */
  32763. protected _environmentIntensity: number;
  32764. /**
  32765. * Intensity of the environment in all pbr material.
  32766. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32767. * As in the majority of the scene they are the same (exception for multi room and so on),
  32768. * this is easier to reference from here than from all the materials.
  32769. */
  32770. /**
  32771. * Intensity of the environment in all pbr material.
  32772. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32773. * As in the majority of the scene they are the same (exception for multi room and so on),
  32774. * this is easier to set here than in all the materials.
  32775. */
  32776. environmentIntensity: number;
  32777. /** @hidden */
  32778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32779. /**
  32780. * Default image processing configuration used either in the rendering
  32781. * Forward main pass or through the imageProcessingPostProcess if present.
  32782. * As in the majority of the scene they are the same (exception for multi camera),
  32783. * this is easier to reference from here than from all the materials and post process.
  32784. *
  32785. * No setter as we it is a shared configuration, you can set the values instead.
  32786. */
  32787. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32788. private _forceWireframe;
  32789. /**
  32790. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32791. */
  32792. forceWireframe: boolean;
  32793. private _forcePointsCloud;
  32794. /**
  32795. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32796. */
  32797. forcePointsCloud: boolean;
  32798. /**
  32799. * Gets or sets the active clipplane 1
  32800. */
  32801. clipPlane: Nullable<Plane>;
  32802. /**
  32803. * Gets or sets the active clipplane 2
  32804. */
  32805. clipPlane2: Nullable<Plane>;
  32806. /**
  32807. * Gets or sets the active clipplane 3
  32808. */
  32809. clipPlane3: Nullable<Plane>;
  32810. /**
  32811. * Gets or sets the active clipplane 4
  32812. */
  32813. clipPlane4: Nullable<Plane>;
  32814. /**
  32815. * Gets or sets a boolean indicating if animations are enabled
  32816. */
  32817. animationsEnabled: boolean;
  32818. private _animationPropertiesOverride;
  32819. /**
  32820. * Gets or sets the animation properties override
  32821. */
  32822. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32823. /**
  32824. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32825. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32826. */
  32827. useConstantAnimationDeltaTime: boolean;
  32828. /**
  32829. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32830. * Please note that it requires to run a ray cast through the scene on every frame
  32831. */
  32832. constantlyUpdateMeshUnderPointer: boolean;
  32833. /**
  32834. * Defines the HTML cursor to use when hovering over interactive elements
  32835. */
  32836. hoverCursor: string;
  32837. /**
  32838. * Defines the HTML default cursor to use (empty by default)
  32839. */
  32840. defaultCursor: string;
  32841. /**
  32842. * This is used to call preventDefault() on pointer down
  32843. * in order to block unwanted artifacts like system double clicks
  32844. */
  32845. preventDefaultOnPointerDown: boolean;
  32846. /**
  32847. * This is used to call preventDefault() on pointer up
  32848. * in order to block unwanted artifacts like system double clicks
  32849. */
  32850. preventDefaultOnPointerUp: boolean;
  32851. /**
  32852. * Gets or sets user defined metadata
  32853. */
  32854. metadata: any;
  32855. /**
  32856. * For internal use only. Please do not use.
  32857. */
  32858. reservedDataStore: any;
  32859. /**
  32860. * Gets the name of the plugin used to load this scene (null by default)
  32861. */
  32862. loadingPluginName: string;
  32863. /**
  32864. * Use this array to add regular expressions used to disable offline support for specific urls
  32865. */
  32866. disableOfflineSupportExceptionRules: RegExp[];
  32867. /**
  32868. * An event triggered when the scene is disposed.
  32869. */
  32870. onDisposeObservable: Observable<Scene>;
  32871. private _onDisposeObserver;
  32872. /** Sets a function to be executed when this scene is disposed. */
  32873. onDispose: () => void;
  32874. /**
  32875. * An event triggered before rendering the scene (right after animations and physics)
  32876. */
  32877. onBeforeRenderObservable: Observable<Scene>;
  32878. private _onBeforeRenderObserver;
  32879. /** Sets a function to be executed before rendering this scene */
  32880. beforeRender: Nullable<() => void>;
  32881. /**
  32882. * An event triggered after rendering the scene
  32883. */
  32884. onAfterRenderObservable: Observable<Scene>;
  32885. /**
  32886. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32887. */
  32888. onAfterRenderCameraObservable: Observable<Camera>;
  32889. private _onAfterRenderObserver;
  32890. /** Sets a function to be executed after rendering this scene */
  32891. afterRender: Nullable<() => void>;
  32892. /**
  32893. * An event triggered before animating the scene
  32894. */
  32895. onBeforeAnimationsObservable: Observable<Scene>;
  32896. /**
  32897. * An event triggered after animations processing
  32898. */
  32899. onAfterAnimationsObservable: Observable<Scene>;
  32900. /**
  32901. * An event triggered before draw calls are ready to be sent
  32902. */
  32903. onBeforeDrawPhaseObservable: Observable<Scene>;
  32904. /**
  32905. * An event triggered after draw calls have been sent
  32906. */
  32907. onAfterDrawPhaseObservable: Observable<Scene>;
  32908. /**
  32909. * An event triggered when the scene is ready
  32910. */
  32911. onReadyObservable: Observable<Scene>;
  32912. /**
  32913. * An event triggered before rendering a camera
  32914. */
  32915. onBeforeCameraRenderObservable: Observable<Camera>;
  32916. private _onBeforeCameraRenderObserver;
  32917. /** Sets a function to be executed before rendering a camera*/
  32918. beforeCameraRender: () => void;
  32919. /**
  32920. * An event triggered after rendering a camera
  32921. */
  32922. onAfterCameraRenderObservable: Observable<Camera>;
  32923. private _onAfterCameraRenderObserver;
  32924. /** Sets a function to be executed after rendering a camera*/
  32925. afterCameraRender: () => void;
  32926. /**
  32927. * An event triggered when active meshes evaluation is about to start
  32928. */
  32929. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32930. /**
  32931. * An event triggered when active meshes evaluation is done
  32932. */
  32933. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32934. /**
  32935. * An event triggered when particles rendering is about to start
  32936. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32937. */
  32938. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32939. /**
  32940. * An event triggered when particles rendering is done
  32941. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32942. */
  32943. onAfterParticlesRenderingObservable: Observable<Scene>;
  32944. /**
  32945. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32946. */
  32947. onDataLoadedObservable: Observable<Scene>;
  32948. /**
  32949. * An event triggered when a camera is created
  32950. */
  32951. onNewCameraAddedObservable: Observable<Camera>;
  32952. /**
  32953. * An event triggered when a camera is removed
  32954. */
  32955. onCameraRemovedObservable: Observable<Camera>;
  32956. /**
  32957. * An event triggered when a light is created
  32958. */
  32959. onNewLightAddedObservable: Observable<Light>;
  32960. /**
  32961. * An event triggered when a light is removed
  32962. */
  32963. onLightRemovedObservable: Observable<Light>;
  32964. /**
  32965. * An event triggered when a geometry is created
  32966. */
  32967. onNewGeometryAddedObservable: Observable<Geometry>;
  32968. /**
  32969. * An event triggered when a geometry is removed
  32970. */
  32971. onGeometryRemovedObservable: Observable<Geometry>;
  32972. /**
  32973. * An event triggered when a transform node is created
  32974. */
  32975. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32976. /**
  32977. * An event triggered when a transform node is removed
  32978. */
  32979. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32980. /**
  32981. * An event triggered when a mesh is created
  32982. */
  32983. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32984. /**
  32985. * An event triggered when a mesh is removed
  32986. */
  32987. onMeshRemovedObservable: Observable<AbstractMesh>;
  32988. /**
  32989. * An event triggered when a skeleton is created
  32990. */
  32991. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32992. /**
  32993. * An event triggered when a skeleton is removed
  32994. */
  32995. onSkeletonRemovedObservable: Observable<Skeleton>;
  32996. /**
  32997. * An event triggered when a material is created
  32998. */
  32999. onNewMaterialAddedObservable: Observable<Material>;
  33000. /**
  33001. * An event triggered when a material is removed
  33002. */
  33003. onMaterialRemovedObservable: Observable<Material>;
  33004. /**
  33005. * An event triggered when a texture is created
  33006. */
  33007. onNewTextureAddedObservable: Observable<BaseTexture>;
  33008. /**
  33009. * An event triggered when a texture is removed
  33010. */
  33011. onTextureRemovedObservable: Observable<BaseTexture>;
  33012. /**
  33013. * An event triggered when render targets are about to be rendered
  33014. * Can happen multiple times per frame.
  33015. */
  33016. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33017. /**
  33018. * An event triggered when render targets were rendered.
  33019. * Can happen multiple times per frame.
  33020. */
  33021. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33022. /**
  33023. * An event triggered before calculating deterministic simulation step
  33024. */
  33025. onBeforeStepObservable: Observable<Scene>;
  33026. /**
  33027. * An event triggered after calculating deterministic simulation step
  33028. */
  33029. onAfterStepObservable: Observable<Scene>;
  33030. /**
  33031. * An event triggered when the activeCamera property is updated
  33032. */
  33033. onActiveCameraChanged: Observable<Scene>;
  33034. /**
  33035. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33036. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33037. * 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)
  33038. */
  33039. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33040. /**
  33041. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33042. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33043. * 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)
  33044. */
  33045. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33046. /**
  33047. * This Observable will when a mesh has been imported into the scene.
  33048. */
  33049. onMeshImportedObservable: Observable<AbstractMesh>;
  33050. /**
  33051. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33052. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33053. */
  33054. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33055. /** @hidden */
  33056. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33057. /**
  33058. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33059. */
  33060. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33061. /**
  33062. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33063. */
  33064. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33065. /**
  33066. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33067. */
  33068. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33069. /** Callback called when a pointer move is detected */
  33070. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33071. /** Callback called when a pointer down is detected */
  33072. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33073. /** Callback called when a pointer up is detected */
  33074. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33075. /** Callback called when a pointer pick is detected */
  33076. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33077. /**
  33078. * 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).
  33079. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33080. */
  33081. onPrePointerObservable: Observable<PointerInfoPre>;
  33082. /**
  33083. * Observable event triggered each time an input event is received from the rendering canvas
  33084. */
  33085. onPointerObservable: Observable<PointerInfo>;
  33086. /**
  33087. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33088. */
  33089. readonly unTranslatedPointer: Vector2;
  33090. /**
  33091. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33092. */
  33093. static DragMovementThreshold: number;
  33094. /**
  33095. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33096. */
  33097. static LongPressDelay: number;
  33098. /**
  33099. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33100. */
  33101. static DoubleClickDelay: number;
  33102. /** If you need to check double click without raising a single click at first click, enable this flag */
  33103. static ExclusiveDoubleClickMode: boolean;
  33104. /** @hidden */
  33105. _mirroredCameraPosition: Nullable<Vector3>;
  33106. /**
  33107. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33108. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33109. */
  33110. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33111. /**
  33112. * Observable event triggered each time an keyboard event is received from the hosting window
  33113. */
  33114. onKeyboardObservable: Observable<KeyboardInfo>;
  33115. private _useRightHandedSystem;
  33116. /**
  33117. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33118. */
  33119. useRightHandedSystem: boolean;
  33120. private _timeAccumulator;
  33121. private _currentStepId;
  33122. private _currentInternalStep;
  33123. /**
  33124. * Sets the step Id used by deterministic lock step
  33125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33126. * @param newStepId defines the step Id
  33127. */
  33128. setStepId(newStepId: number): void;
  33129. /**
  33130. * Gets the step Id used by deterministic lock step
  33131. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33132. * @returns the step Id
  33133. */
  33134. getStepId(): number;
  33135. /**
  33136. * Gets the internal step used by deterministic lock step
  33137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33138. * @returns the internal step
  33139. */
  33140. getInternalStep(): number;
  33141. private _fogEnabled;
  33142. /**
  33143. * Gets or sets a boolean indicating if fog is enabled on this scene
  33144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33145. * (Default is true)
  33146. */
  33147. fogEnabled: boolean;
  33148. private _fogMode;
  33149. /**
  33150. * Gets or sets the fog mode to use
  33151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33152. * | mode | value |
  33153. * | --- | --- |
  33154. * | FOGMODE_NONE | 0 |
  33155. * | FOGMODE_EXP | 1 |
  33156. * | FOGMODE_EXP2 | 2 |
  33157. * | FOGMODE_LINEAR | 3 |
  33158. */
  33159. fogMode: number;
  33160. /**
  33161. * Gets or sets the fog color to use
  33162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33163. * (Default is Color3(0.2, 0.2, 0.3))
  33164. */
  33165. fogColor: Color3;
  33166. /**
  33167. * Gets or sets the fog density to use
  33168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33169. * (Default is 0.1)
  33170. */
  33171. fogDensity: number;
  33172. /**
  33173. * Gets or sets the fog start distance to use
  33174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33175. * (Default is 0)
  33176. */
  33177. fogStart: number;
  33178. /**
  33179. * Gets or sets the fog end distance to use
  33180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33181. * (Default is 1000)
  33182. */
  33183. fogEnd: number;
  33184. private _shadowsEnabled;
  33185. /**
  33186. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33187. */
  33188. shadowsEnabled: boolean;
  33189. private _lightsEnabled;
  33190. /**
  33191. * Gets or sets a boolean indicating if lights are enabled on this scene
  33192. */
  33193. lightsEnabled: boolean;
  33194. /** All of the active cameras added to this scene. */
  33195. activeCameras: Camera[];
  33196. /** @hidden */
  33197. _activeCamera: Nullable<Camera>;
  33198. /** Gets or sets the current active camera */
  33199. activeCamera: Nullable<Camera>;
  33200. private _defaultMaterial;
  33201. /** The default material used on meshes when no material is affected */
  33202. /** The default material used on meshes when no material is affected */
  33203. defaultMaterial: Material;
  33204. private _texturesEnabled;
  33205. /**
  33206. * Gets or sets a boolean indicating if textures are enabled on this scene
  33207. */
  33208. texturesEnabled: boolean;
  33209. /**
  33210. * Gets or sets a boolean indicating if particles are enabled on this scene
  33211. */
  33212. particlesEnabled: boolean;
  33213. /**
  33214. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33215. */
  33216. spritesEnabled: boolean;
  33217. private _skeletonsEnabled;
  33218. /**
  33219. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33220. */
  33221. skeletonsEnabled: boolean;
  33222. /**
  33223. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33224. */
  33225. lensFlaresEnabled: boolean;
  33226. /**
  33227. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33229. */
  33230. collisionsEnabled: boolean;
  33231. private _collisionCoordinator;
  33232. /** @hidden */
  33233. readonly collisionCoordinator: ICollisionCoordinator;
  33234. /**
  33235. * Defines the gravity applied to this scene (used only for collisions)
  33236. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33237. */
  33238. gravity: Vector3;
  33239. /**
  33240. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33241. */
  33242. postProcessesEnabled: boolean;
  33243. /**
  33244. * The list of postprocesses added to the scene
  33245. */
  33246. postProcesses: PostProcess[];
  33247. /**
  33248. * Gets the current postprocess manager
  33249. */
  33250. postProcessManager: PostProcessManager;
  33251. /**
  33252. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33253. */
  33254. renderTargetsEnabled: boolean;
  33255. /**
  33256. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33257. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33258. */
  33259. dumpNextRenderTargets: boolean;
  33260. /**
  33261. * The list of user defined render targets added to the scene
  33262. */
  33263. customRenderTargets: RenderTargetTexture[];
  33264. /**
  33265. * Defines if texture loading must be delayed
  33266. * If true, textures will only be loaded when they need to be rendered
  33267. */
  33268. useDelayedTextureLoading: boolean;
  33269. /**
  33270. * Gets the list of meshes imported to the scene through SceneLoader
  33271. */
  33272. importedMeshesFiles: String[];
  33273. /**
  33274. * Gets or sets a boolean indicating if probes are enabled on this scene
  33275. */
  33276. probesEnabled: boolean;
  33277. /**
  33278. * Gets or sets the current offline provider to use to store scene data
  33279. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33280. */
  33281. offlineProvider: IOfflineProvider;
  33282. /**
  33283. * Gets or sets the action manager associated with the scene
  33284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33285. */
  33286. actionManager: AbstractActionManager;
  33287. private _meshesForIntersections;
  33288. /**
  33289. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33290. */
  33291. proceduralTexturesEnabled: boolean;
  33292. private _engine;
  33293. private _totalVertices;
  33294. /** @hidden */
  33295. _activeIndices: PerfCounter;
  33296. /** @hidden */
  33297. _activeParticles: PerfCounter;
  33298. /** @hidden */
  33299. _activeBones: PerfCounter;
  33300. private _animationRatio;
  33301. /** @hidden */
  33302. _animationTimeLast: number;
  33303. /** @hidden */
  33304. _animationTime: number;
  33305. /**
  33306. * Gets or sets a general scale for animation speed
  33307. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33308. */
  33309. animationTimeScale: number;
  33310. /** @hidden */
  33311. _cachedMaterial: Nullable<Material>;
  33312. /** @hidden */
  33313. _cachedEffect: Nullable<Effect>;
  33314. /** @hidden */
  33315. _cachedVisibility: Nullable<number>;
  33316. private _renderId;
  33317. private _frameId;
  33318. private _executeWhenReadyTimeoutId;
  33319. private _intermediateRendering;
  33320. private _viewUpdateFlag;
  33321. private _projectionUpdateFlag;
  33322. /** @hidden */
  33323. _toBeDisposed: Nullable<IDisposable>[];
  33324. private _activeRequests;
  33325. /** @hidden */
  33326. _pendingData: any[];
  33327. private _isDisposed;
  33328. /**
  33329. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33330. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33331. */
  33332. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33333. private _activeMeshes;
  33334. private _processedMaterials;
  33335. private _renderTargets;
  33336. /** @hidden */
  33337. _activeParticleSystems: SmartArray<IParticleSystem>;
  33338. private _activeSkeletons;
  33339. private _softwareSkinnedMeshes;
  33340. private _renderingManager;
  33341. /** @hidden */
  33342. _activeAnimatables: Animatable[];
  33343. private _transformMatrix;
  33344. private _sceneUbo;
  33345. /** @hidden */
  33346. _viewMatrix: Matrix;
  33347. private _projectionMatrix;
  33348. /** @hidden */
  33349. _forcedViewPosition: Nullable<Vector3>;
  33350. /** @hidden */
  33351. _frustumPlanes: Plane[];
  33352. /**
  33353. * Gets the list of frustum planes (built from the active camera)
  33354. */
  33355. readonly frustumPlanes: Plane[];
  33356. /**
  33357. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33358. * This is useful if there are more lights that the maximum simulteanous authorized
  33359. */
  33360. requireLightSorting: boolean;
  33361. /** @hidden */
  33362. readonly useMaterialMeshMap: boolean;
  33363. /** @hidden */
  33364. readonly useClonedMeshhMap: boolean;
  33365. private _externalData;
  33366. private _uid;
  33367. /**
  33368. * @hidden
  33369. * Backing store of defined scene components.
  33370. */
  33371. _components: ISceneComponent[];
  33372. /**
  33373. * @hidden
  33374. * Backing store of defined scene components.
  33375. */
  33376. _serializableComponents: ISceneSerializableComponent[];
  33377. /**
  33378. * List of components to register on the next registration step.
  33379. */
  33380. private _transientComponents;
  33381. /**
  33382. * Registers the transient components if needed.
  33383. */
  33384. private _registerTransientComponents;
  33385. /**
  33386. * @hidden
  33387. * Add a component to the scene.
  33388. * Note that the ccomponent could be registered on th next frame if this is called after
  33389. * the register component stage.
  33390. * @param component Defines the component to add to the scene
  33391. */
  33392. _addComponent(component: ISceneComponent): void;
  33393. /**
  33394. * @hidden
  33395. * Gets a component from the scene.
  33396. * @param name defines the name of the component to retrieve
  33397. * @returns the component or null if not present
  33398. */
  33399. _getComponent(name: string): Nullable<ISceneComponent>;
  33400. /**
  33401. * @hidden
  33402. * Defines the actions happening before camera updates.
  33403. */
  33404. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33405. /**
  33406. * @hidden
  33407. * Defines the actions happening before clear the canvas.
  33408. */
  33409. _beforeClearStage: Stage<SimpleStageAction>;
  33410. /**
  33411. * @hidden
  33412. * Defines the actions when collecting render targets for the frame.
  33413. */
  33414. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33415. /**
  33416. * @hidden
  33417. * Defines the actions happening for one camera in the frame.
  33418. */
  33419. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33420. /**
  33421. * @hidden
  33422. * Defines the actions happening during the per mesh ready checks.
  33423. */
  33424. _isReadyForMeshStage: Stage<MeshStageAction>;
  33425. /**
  33426. * @hidden
  33427. * Defines the actions happening before evaluate active mesh checks.
  33428. */
  33429. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33430. /**
  33431. * @hidden
  33432. * Defines the actions happening during the evaluate sub mesh checks.
  33433. */
  33434. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33435. /**
  33436. * @hidden
  33437. * Defines the actions happening during the active mesh stage.
  33438. */
  33439. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33440. /**
  33441. * @hidden
  33442. * Defines the actions happening during the per camera render target step.
  33443. */
  33444. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33445. /**
  33446. * @hidden
  33447. * Defines the actions happening just before the active camera is drawing.
  33448. */
  33449. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33450. /**
  33451. * @hidden
  33452. * Defines the actions happening just before a render target is drawing.
  33453. */
  33454. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33455. /**
  33456. * @hidden
  33457. * Defines the actions happening just before a rendering group is drawing.
  33458. */
  33459. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening just before a mesh is drawing.
  33463. */
  33464. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening just after a mesh has been drawn.
  33468. */
  33469. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions happening just after a rendering group has been drawn.
  33473. */
  33474. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening just after the active camera has been drawn.
  33478. */
  33479. _afterCameraDrawStage: Stage<CameraStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening just after a render target has been drawn.
  33483. */
  33484. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening just after rendering all cameras and computing intersections.
  33488. */
  33489. _afterRenderStage: Stage<SimpleStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening when a pointer move event happens.
  33493. */
  33494. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening when a pointer down event happens.
  33498. */
  33499. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33500. /**
  33501. * @hidden
  33502. * Defines the actions happening when a pointer up event happens.
  33503. */
  33504. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33505. /**
  33506. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33507. */
  33508. private geometriesByUniqueId;
  33509. /**
  33510. * Creates a new Scene
  33511. * @param engine defines the engine to use to render this scene
  33512. * @param options defines the scene options
  33513. */
  33514. constructor(engine: Engine, options?: SceneOptions);
  33515. /**
  33516. * Gets a string idenfifying the name of the class
  33517. * @returns "Scene" string
  33518. */
  33519. getClassName(): string;
  33520. private _defaultMeshCandidates;
  33521. /**
  33522. * @hidden
  33523. */
  33524. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33525. private _defaultSubMeshCandidates;
  33526. /**
  33527. * @hidden
  33528. */
  33529. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33530. /**
  33531. * Sets the default candidate providers for the scene.
  33532. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33533. * and getCollidingSubMeshCandidates to their default function
  33534. */
  33535. setDefaultCandidateProviders(): void;
  33536. /**
  33537. * Gets the mesh that is currently under the pointer
  33538. */
  33539. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33540. /**
  33541. * Gets or sets the current on-screen X position of the pointer
  33542. */
  33543. pointerX: number;
  33544. /**
  33545. * Gets or sets the current on-screen Y position of the pointer
  33546. */
  33547. pointerY: number;
  33548. /**
  33549. * Gets the cached material (ie. the latest rendered one)
  33550. * @returns the cached material
  33551. */
  33552. getCachedMaterial(): Nullable<Material>;
  33553. /**
  33554. * Gets the cached effect (ie. the latest rendered one)
  33555. * @returns the cached effect
  33556. */
  33557. getCachedEffect(): Nullable<Effect>;
  33558. /**
  33559. * Gets the cached visibility state (ie. the latest rendered one)
  33560. * @returns the cached visibility state
  33561. */
  33562. getCachedVisibility(): Nullable<number>;
  33563. /**
  33564. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33565. * @param material defines the current material
  33566. * @param effect defines the current effect
  33567. * @param visibility defines the current visibility state
  33568. * @returns true if one parameter is not cached
  33569. */
  33570. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33571. /**
  33572. * Gets the engine associated with the scene
  33573. * @returns an Engine
  33574. */
  33575. getEngine(): Engine;
  33576. /**
  33577. * Gets the total number of vertices rendered per frame
  33578. * @returns the total number of vertices rendered per frame
  33579. */
  33580. getTotalVertices(): number;
  33581. /**
  33582. * Gets the performance counter for total vertices
  33583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33584. */
  33585. readonly totalVerticesPerfCounter: PerfCounter;
  33586. /**
  33587. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33588. * @returns the total number of active indices rendered per frame
  33589. */
  33590. getActiveIndices(): number;
  33591. /**
  33592. * Gets the performance counter for active indices
  33593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33594. */
  33595. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33596. /**
  33597. * Gets the total number of active particles rendered per frame
  33598. * @returns the total number of active particles rendered per frame
  33599. */
  33600. getActiveParticles(): number;
  33601. /**
  33602. * Gets the performance counter for active particles
  33603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33604. */
  33605. readonly activeParticlesPerfCounter: PerfCounter;
  33606. /**
  33607. * Gets the total number of active bones rendered per frame
  33608. * @returns the total number of active bones rendered per frame
  33609. */
  33610. getActiveBones(): number;
  33611. /**
  33612. * Gets the performance counter for active bones
  33613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33614. */
  33615. readonly activeBonesPerfCounter: PerfCounter;
  33616. /**
  33617. * Gets the array of active meshes
  33618. * @returns an array of AbstractMesh
  33619. */
  33620. getActiveMeshes(): SmartArray<AbstractMesh>;
  33621. /**
  33622. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33623. * @returns a number
  33624. */
  33625. getAnimationRatio(): number;
  33626. /**
  33627. * Gets an unique Id for the current render phase
  33628. * @returns a number
  33629. */
  33630. getRenderId(): number;
  33631. /**
  33632. * Gets an unique Id for the current frame
  33633. * @returns a number
  33634. */
  33635. getFrameId(): number;
  33636. /** Call this function if you want to manually increment the render Id*/
  33637. incrementRenderId(): void;
  33638. private _createUbo;
  33639. /**
  33640. * Use this method to simulate a pointer move on a mesh
  33641. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33642. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33643. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33644. * @returns the current scene
  33645. */
  33646. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33647. /**
  33648. * Use this method to simulate a pointer down on a mesh
  33649. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33650. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33651. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33652. * @returns the current scene
  33653. */
  33654. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33655. /**
  33656. * Use this method to simulate a pointer up on a mesh
  33657. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33658. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33659. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33660. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33661. * @returns the current scene
  33662. */
  33663. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33664. /**
  33665. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33666. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33667. * @returns true if the pointer was captured
  33668. */
  33669. isPointerCaptured(pointerId?: number): boolean;
  33670. /**
  33671. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33672. * @param attachUp defines if you want to attach events to pointerup
  33673. * @param attachDown defines if you want to attach events to pointerdown
  33674. * @param attachMove defines if you want to attach events to pointermove
  33675. */
  33676. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33677. /** Detaches all event handlers*/
  33678. detachControl(): void;
  33679. /**
  33680. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33681. * Delay loaded resources are not taking in account
  33682. * @return true if all required resources are ready
  33683. */
  33684. isReady(): boolean;
  33685. /** Resets all cached information relative to material (including effect and visibility) */
  33686. resetCachedMaterial(): void;
  33687. /**
  33688. * Registers a function to be called before every frame render
  33689. * @param func defines the function to register
  33690. */
  33691. registerBeforeRender(func: () => void): void;
  33692. /**
  33693. * Unregisters a function called before every frame render
  33694. * @param func defines the function to unregister
  33695. */
  33696. unregisterBeforeRender(func: () => void): void;
  33697. /**
  33698. * Registers a function to be called after every frame render
  33699. * @param func defines the function to register
  33700. */
  33701. registerAfterRender(func: () => void): void;
  33702. /**
  33703. * Unregisters a function called after every frame render
  33704. * @param func defines the function to unregister
  33705. */
  33706. unregisterAfterRender(func: () => void): void;
  33707. private _executeOnceBeforeRender;
  33708. /**
  33709. * The provided function will run before render once and will be disposed afterwards.
  33710. * A timeout delay can be provided so that the function will be executed in N ms.
  33711. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33712. * @param func The function to be executed.
  33713. * @param timeout optional delay in ms
  33714. */
  33715. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33716. /** @hidden */
  33717. _addPendingData(data: any): void;
  33718. /** @hidden */
  33719. _removePendingData(data: any): void;
  33720. /**
  33721. * Returns the number of items waiting to be loaded
  33722. * @returns the number of items waiting to be loaded
  33723. */
  33724. getWaitingItemsCount(): number;
  33725. /**
  33726. * Returns a boolean indicating if the scene is still loading data
  33727. */
  33728. readonly isLoading: boolean;
  33729. /**
  33730. * Registers a function to be executed when the scene is ready
  33731. * @param {Function} func - the function to be executed
  33732. */
  33733. executeWhenReady(func: () => void): void;
  33734. /**
  33735. * Returns a promise that resolves when the scene is ready
  33736. * @returns A promise that resolves when the scene is ready
  33737. */
  33738. whenReadyAsync(): Promise<void>;
  33739. /** @hidden */
  33740. _checkIsReady(): void;
  33741. /**
  33742. * Gets all animatable attached to the scene
  33743. */
  33744. readonly animatables: Animatable[];
  33745. /**
  33746. * Resets the last animation time frame.
  33747. * Useful to override when animations start running when loading a scene for the first time.
  33748. */
  33749. resetLastAnimationTimeFrame(): void;
  33750. /**
  33751. * Gets the current view matrix
  33752. * @returns a Matrix
  33753. */
  33754. getViewMatrix(): Matrix;
  33755. /**
  33756. * Gets the current projection matrix
  33757. * @returns a Matrix
  33758. */
  33759. getProjectionMatrix(): Matrix;
  33760. /**
  33761. * Gets the current transform matrix
  33762. * @returns a Matrix made of View * Projection
  33763. */
  33764. getTransformMatrix(): Matrix;
  33765. /**
  33766. * Sets the current transform matrix
  33767. * @param viewL defines the View matrix to use
  33768. * @param projectionL defines the Projection matrix to use
  33769. * @param viewR defines the right View matrix to use (if provided)
  33770. * @param projectionR defines the right Projection matrix to use (if provided)
  33771. */
  33772. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33773. /**
  33774. * Gets the uniform buffer used to store scene data
  33775. * @returns a UniformBuffer
  33776. */
  33777. getSceneUniformBuffer(): UniformBuffer;
  33778. /**
  33779. * Gets an unique (relatively to the current scene) Id
  33780. * @returns an unique number for the scene
  33781. */
  33782. getUniqueId(): number;
  33783. /**
  33784. * Add a mesh to the list of scene's meshes
  33785. * @param newMesh defines the mesh to add
  33786. * @param recursive if all child meshes should also be added to the scene
  33787. */
  33788. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33789. /**
  33790. * Remove a mesh for the list of scene's meshes
  33791. * @param toRemove defines the mesh to remove
  33792. * @param recursive if all child meshes should also be removed from the scene
  33793. * @returns the index where the mesh was in the mesh list
  33794. */
  33795. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33796. /**
  33797. * Add a transform node to the list of scene's transform nodes
  33798. * @param newTransformNode defines the transform node to add
  33799. */
  33800. addTransformNode(newTransformNode: TransformNode): void;
  33801. /**
  33802. * Remove a transform node for the list of scene's transform nodes
  33803. * @param toRemove defines the transform node to remove
  33804. * @returns the index where the transform node was in the transform node list
  33805. */
  33806. removeTransformNode(toRemove: TransformNode): number;
  33807. /**
  33808. * Remove a skeleton for the list of scene's skeletons
  33809. * @param toRemove defines the skeleton to remove
  33810. * @returns the index where the skeleton was in the skeleton list
  33811. */
  33812. removeSkeleton(toRemove: Skeleton): number;
  33813. /**
  33814. * Remove a morph target for the list of scene's morph targets
  33815. * @param toRemove defines the morph target to remove
  33816. * @returns the index where the morph target was in the morph target list
  33817. */
  33818. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33819. /**
  33820. * Remove a light for the list of scene's lights
  33821. * @param toRemove defines the light to remove
  33822. * @returns the index where the light was in the light list
  33823. */
  33824. removeLight(toRemove: Light): number;
  33825. /**
  33826. * Remove a camera for the list of scene's cameras
  33827. * @param toRemove defines the camera to remove
  33828. * @returns the index where the camera was in the camera list
  33829. */
  33830. removeCamera(toRemove: Camera): number;
  33831. /**
  33832. * Remove a particle system for the list of scene's particle systems
  33833. * @param toRemove defines the particle system to remove
  33834. * @returns the index where the particle system was in the particle system list
  33835. */
  33836. removeParticleSystem(toRemove: IParticleSystem): number;
  33837. /**
  33838. * Remove a animation for the list of scene's animations
  33839. * @param toRemove defines the animation to remove
  33840. * @returns the index where the animation was in the animation list
  33841. */
  33842. removeAnimation(toRemove: Animation): number;
  33843. /**
  33844. * Will stop the animation of the given target
  33845. * @param target - the target
  33846. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33847. * @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)
  33848. */
  33849. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33850. /**
  33851. * Removes the given animation group from this scene.
  33852. * @param toRemove The animation group to remove
  33853. * @returns The index of the removed animation group
  33854. */
  33855. removeAnimationGroup(toRemove: AnimationGroup): number;
  33856. /**
  33857. * Removes the given multi-material from this scene.
  33858. * @param toRemove The multi-material to remove
  33859. * @returns The index of the removed multi-material
  33860. */
  33861. removeMultiMaterial(toRemove: MultiMaterial): number;
  33862. /**
  33863. * Removes the given material from this scene.
  33864. * @param toRemove The material to remove
  33865. * @returns The index of the removed material
  33866. */
  33867. removeMaterial(toRemove: Material): number;
  33868. /**
  33869. * Removes the given action manager from this scene.
  33870. * @param toRemove The action manager to remove
  33871. * @returns The index of the removed action manager
  33872. */
  33873. removeActionManager(toRemove: AbstractActionManager): number;
  33874. /**
  33875. * Removes the given texture from this scene.
  33876. * @param toRemove The texture to remove
  33877. * @returns The index of the removed texture
  33878. */
  33879. removeTexture(toRemove: BaseTexture): number;
  33880. /**
  33881. * Adds the given light to this scene
  33882. * @param newLight The light to add
  33883. */
  33884. addLight(newLight: Light): void;
  33885. /**
  33886. * Sorts the list list based on light priorities
  33887. */
  33888. sortLightsByPriority(): void;
  33889. /**
  33890. * Adds the given camera to this scene
  33891. * @param newCamera The camera to add
  33892. */
  33893. addCamera(newCamera: Camera): void;
  33894. /**
  33895. * Adds the given skeleton to this scene
  33896. * @param newSkeleton The skeleton to add
  33897. */
  33898. addSkeleton(newSkeleton: Skeleton): void;
  33899. /**
  33900. * Adds the given particle system to this scene
  33901. * @param newParticleSystem The particle system to add
  33902. */
  33903. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33904. /**
  33905. * Adds the given animation to this scene
  33906. * @param newAnimation The animation to add
  33907. */
  33908. addAnimation(newAnimation: Animation): void;
  33909. /**
  33910. * Adds the given animation group to this scene.
  33911. * @param newAnimationGroup The animation group to add
  33912. */
  33913. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33914. /**
  33915. * Adds the given multi-material to this scene
  33916. * @param newMultiMaterial The multi-material to add
  33917. */
  33918. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33919. /**
  33920. * Adds the given material to this scene
  33921. * @param newMaterial The material to add
  33922. */
  33923. addMaterial(newMaterial: Material): void;
  33924. /**
  33925. * Adds the given morph target to this scene
  33926. * @param newMorphTargetManager The morph target to add
  33927. */
  33928. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33929. /**
  33930. * Adds the given geometry to this scene
  33931. * @param newGeometry The geometry to add
  33932. */
  33933. addGeometry(newGeometry: Geometry): void;
  33934. /**
  33935. * Adds the given action manager to this scene
  33936. * @param newActionManager The action manager to add
  33937. */
  33938. addActionManager(newActionManager: AbstractActionManager): void;
  33939. /**
  33940. * Adds the given texture to this scene.
  33941. * @param newTexture The texture to add
  33942. */
  33943. addTexture(newTexture: BaseTexture): void;
  33944. /**
  33945. * Switch active camera
  33946. * @param newCamera defines the new active camera
  33947. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33948. */
  33949. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33950. /**
  33951. * sets the active camera of the scene using its ID
  33952. * @param id defines the camera's ID
  33953. * @return the new active camera or null if none found.
  33954. */
  33955. setActiveCameraByID(id: string): Nullable<Camera>;
  33956. /**
  33957. * sets the active camera of the scene using its name
  33958. * @param name defines the camera's name
  33959. * @returns the new active camera or null if none found.
  33960. */
  33961. setActiveCameraByName(name: string): Nullable<Camera>;
  33962. /**
  33963. * get an animation group using its name
  33964. * @param name defines the material's name
  33965. * @return the animation group or null if none found.
  33966. */
  33967. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33968. /**
  33969. * Get a material using its unique id
  33970. * @param uniqueId defines the material's unique id
  33971. * @return the material or null if none found.
  33972. */
  33973. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33974. /**
  33975. * get a material using its id
  33976. * @param id defines the material's ID
  33977. * @return the material or null if none found.
  33978. */
  33979. getMaterialByID(id: string): Nullable<Material>;
  33980. /**
  33981. * Gets a the last added material using a given id
  33982. * @param id defines the material's ID
  33983. * @return the last material with the given id or null if none found.
  33984. */
  33985. getLastMaterialByID(id: string): Nullable<Material>;
  33986. /**
  33987. * Gets a material using its name
  33988. * @param name defines the material's name
  33989. * @return the material or null if none found.
  33990. */
  33991. getMaterialByName(name: string): Nullable<Material>;
  33992. /**
  33993. * Get a texture using its unique id
  33994. * @param uniqueId defines the texture's unique id
  33995. * @return the texture or null if none found.
  33996. */
  33997. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33998. /**
  33999. * Gets a camera using its id
  34000. * @param id defines the id to look for
  34001. * @returns the camera or null if not found
  34002. */
  34003. getCameraByID(id: string): Nullable<Camera>;
  34004. /**
  34005. * Gets a camera using its unique id
  34006. * @param uniqueId defines the unique id to look for
  34007. * @returns the camera or null if not found
  34008. */
  34009. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34010. /**
  34011. * Gets a camera using its name
  34012. * @param name defines the camera's name
  34013. * @return the camera or null if none found.
  34014. */
  34015. getCameraByName(name: string): Nullable<Camera>;
  34016. /**
  34017. * Gets a bone using its id
  34018. * @param id defines the bone's id
  34019. * @return the bone or null if not found
  34020. */
  34021. getBoneByID(id: string): Nullable<Bone>;
  34022. /**
  34023. * Gets a bone using its id
  34024. * @param name defines the bone's name
  34025. * @return the bone or null if not found
  34026. */
  34027. getBoneByName(name: string): Nullable<Bone>;
  34028. /**
  34029. * Gets a light node using its name
  34030. * @param name defines the the light's name
  34031. * @return the light or null if none found.
  34032. */
  34033. getLightByName(name: string): Nullable<Light>;
  34034. /**
  34035. * Gets a light node using its id
  34036. * @param id defines the light's id
  34037. * @return the light or null if none found.
  34038. */
  34039. getLightByID(id: string): Nullable<Light>;
  34040. /**
  34041. * Gets a light node using its scene-generated unique ID
  34042. * @param uniqueId defines the light's unique id
  34043. * @return the light or null if none found.
  34044. */
  34045. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34046. /**
  34047. * Gets a particle system by id
  34048. * @param id defines the particle system id
  34049. * @return the corresponding system or null if none found
  34050. */
  34051. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34052. /**
  34053. * Gets a geometry using its ID
  34054. * @param id defines the geometry's id
  34055. * @return the geometry or null if none found.
  34056. */
  34057. getGeometryByID(id: string): Nullable<Geometry>;
  34058. private _getGeometryByUniqueID;
  34059. /**
  34060. * Add a new geometry to this scene
  34061. * @param geometry defines the geometry to be added to the scene.
  34062. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34063. * @return a boolean defining if the geometry was added or not
  34064. */
  34065. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34066. /**
  34067. * Removes an existing geometry
  34068. * @param geometry defines the geometry to be removed from the scene
  34069. * @return a boolean defining if the geometry was removed or not
  34070. */
  34071. removeGeometry(geometry: Geometry): boolean;
  34072. /**
  34073. * Gets the list of geometries attached to the scene
  34074. * @returns an array of Geometry
  34075. */
  34076. getGeometries(): Geometry[];
  34077. /**
  34078. * Gets the first added mesh found of a given ID
  34079. * @param id defines the id to search for
  34080. * @return the mesh found or null if not found at all
  34081. */
  34082. getMeshByID(id: string): Nullable<AbstractMesh>;
  34083. /**
  34084. * Gets a list of meshes using their id
  34085. * @param id defines the id to search for
  34086. * @returns a list of meshes
  34087. */
  34088. getMeshesByID(id: string): Array<AbstractMesh>;
  34089. /**
  34090. * Gets the first added transform node found of a given ID
  34091. * @param id defines the id to search for
  34092. * @return the found transform node or null if not found at all.
  34093. */
  34094. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34095. /**
  34096. * Gets a transform node with its auto-generated unique id
  34097. * @param uniqueId efines the unique id to search for
  34098. * @return the found transform node or null if not found at all.
  34099. */
  34100. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34101. /**
  34102. * Gets a list of transform nodes using their id
  34103. * @param id defines the id to search for
  34104. * @returns a list of transform nodes
  34105. */
  34106. getTransformNodesByID(id: string): Array<TransformNode>;
  34107. /**
  34108. * Gets a mesh with its auto-generated unique id
  34109. * @param uniqueId defines the unique id to search for
  34110. * @return the found mesh or null if not found at all.
  34111. */
  34112. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34113. /**
  34114. * Gets a the last added mesh using a given id
  34115. * @param id defines the id to search for
  34116. * @return the found mesh or null if not found at all.
  34117. */
  34118. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34119. /**
  34120. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34121. * @param id defines the id to search for
  34122. * @return the found node or null if not found at all
  34123. */
  34124. getLastEntryByID(id: string): Nullable<Node>;
  34125. /**
  34126. * Gets a node (Mesh, Camera, Light) using a given id
  34127. * @param id defines the id to search for
  34128. * @return the found node or null if not found at all
  34129. */
  34130. getNodeByID(id: string): Nullable<Node>;
  34131. /**
  34132. * Gets a node (Mesh, Camera, Light) using a given name
  34133. * @param name defines the name to search for
  34134. * @return the found node or null if not found at all.
  34135. */
  34136. getNodeByName(name: string): Nullable<Node>;
  34137. /**
  34138. * Gets a mesh using a given name
  34139. * @param name defines the name to search for
  34140. * @return the found mesh or null if not found at all.
  34141. */
  34142. getMeshByName(name: string): Nullable<AbstractMesh>;
  34143. /**
  34144. * Gets a transform node using a given name
  34145. * @param name defines the name to search for
  34146. * @return the found transform node or null if not found at all.
  34147. */
  34148. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34149. /**
  34150. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34151. * @param id defines the id to search for
  34152. * @return the found skeleton or null if not found at all.
  34153. */
  34154. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34155. /**
  34156. * Gets a skeleton using a given auto generated unique id
  34157. * @param uniqueId defines the unique id to search for
  34158. * @return the found skeleton or null if not found at all.
  34159. */
  34160. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34161. /**
  34162. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34163. * @param id defines the id to search for
  34164. * @return the found skeleton or null if not found at all.
  34165. */
  34166. getSkeletonById(id: string): Nullable<Skeleton>;
  34167. /**
  34168. * Gets a skeleton using a given name
  34169. * @param name defines the name to search for
  34170. * @return the found skeleton or null if not found at all.
  34171. */
  34172. getSkeletonByName(name: string): Nullable<Skeleton>;
  34173. /**
  34174. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34175. * @param id defines the id to search for
  34176. * @return the found morph target manager or null if not found at all.
  34177. */
  34178. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34179. /**
  34180. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34181. * @param id defines the id to search for
  34182. * @return the found morph target or null if not found at all.
  34183. */
  34184. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34185. /**
  34186. * Gets a boolean indicating if the given mesh is active
  34187. * @param mesh defines the mesh to look for
  34188. * @returns true if the mesh is in the active list
  34189. */
  34190. isActiveMesh(mesh: AbstractMesh): boolean;
  34191. /**
  34192. * Return a unique id as a string which can serve as an identifier for the scene
  34193. */
  34194. readonly uid: string;
  34195. /**
  34196. * Add an externaly attached data from its key.
  34197. * This method call will fail and return false, if such key already exists.
  34198. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34199. * @param key the unique key that identifies the data
  34200. * @param data the data object to associate to the key for this Engine instance
  34201. * @return true if no such key were already present and the data was added successfully, false otherwise
  34202. */
  34203. addExternalData<T>(key: string, data: T): boolean;
  34204. /**
  34205. * Get an externaly attached data from its key
  34206. * @param key the unique key that identifies the data
  34207. * @return the associated data, if present (can be null), or undefined if not present
  34208. */
  34209. getExternalData<T>(key: string): Nullable<T>;
  34210. /**
  34211. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34212. * @param key the unique key that identifies the data
  34213. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34214. * @return the associated data, can be null if the factory returned null.
  34215. */
  34216. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34217. /**
  34218. * Remove an externaly attached data from the Engine instance
  34219. * @param key the unique key that identifies the data
  34220. * @return true if the data was successfully removed, false if it doesn't exist
  34221. */
  34222. removeExternalData(key: string): boolean;
  34223. private _evaluateSubMesh;
  34224. /**
  34225. * Clear the processed materials smart array preventing retention point in material dispose.
  34226. */
  34227. freeProcessedMaterials(): void;
  34228. private _preventFreeActiveMeshesAndRenderingGroups;
  34229. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34230. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34231. * when disposing several meshes in a row or a hierarchy of meshes.
  34232. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34233. */
  34234. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34235. /**
  34236. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34237. */
  34238. freeActiveMeshes(): void;
  34239. /**
  34240. * Clear the info related to rendering groups preventing retention points during dispose.
  34241. */
  34242. freeRenderingGroups(): void;
  34243. /** @hidden */
  34244. _isInIntermediateRendering(): boolean;
  34245. /**
  34246. * Lambda returning the list of potentially active meshes.
  34247. */
  34248. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34249. /**
  34250. * Lambda returning the list of potentially active sub meshes.
  34251. */
  34252. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34253. /**
  34254. * Lambda returning the list of potentially intersecting sub meshes.
  34255. */
  34256. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34257. /**
  34258. * Lambda returning the list of potentially colliding sub meshes.
  34259. */
  34260. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34261. private _activeMeshesFrozen;
  34262. /**
  34263. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34264. * @returns the current scene
  34265. */
  34266. freezeActiveMeshes(): Scene;
  34267. /**
  34268. * Use this function to restart evaluating active meshes on every frame
  34269. * @returns the current scene
  34270. */
  34271. unfreezeActiveMeshes(): Scene;
  34272. private _evaluateActiveMeshes;
  34273. private _activeMesh;
  34274. /**
  34275. * Update the transform matrix to update from the current active camera
  34276. * @param force defines a boolean used to force the update even if cache is up to date
  34277. */
  34278. updateTransformMatrix(force?: boolean): void;
  34279. private _bindFrameBuffer;
  34280. /** @hidden */
  34281. _allowPostProcessClearColor: boolean;
  34282. /** @hidden */
  34283. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34284. private _processSubCameras;
  34285. private _checkIntersections;
  34286. /** @hidden */
  34287. _advancePhysicsEngineStep(step: number): void;
  34288. /**
  34289. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34290. */
  34291. getDeterministicFrameTime: () => number;
  34292. /** @hidden */
  34293. _animate(): void;
  34294. /** Execute all animations (for a frame) */
  34295. animate(): void;
  34296. /**
  34297. * Render the scene
  34298. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34299. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34300. */
  34301. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34302. /**
  34303. * Freeze all materials
  34304. * A frozen material will not be updatable but should be faster to render
  34305. */
  34306. freezeMaterials(): void;
  34307. /**
  34308. * Unfreeze all materials
  34309. * A frozen material will not be updatable but should be faster to render
  34310. */
  34311. unfreezeMaterials(): void;
  34312. /**
  34313. * Releases all held ressources
  34314. */
  34315. dispose(): void;
  34316. /**
  34317. * Gets if the scene is already disposed
  34318. */
  34319. readonly isDisposed: boolean;
  34320. /**
  34321. * Call this function to reduce memory footprint of the scene.
  34322. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34323. */
  34324. clearCachedVertexData(): void;
  34325. /**
  34326. * This function will remove the local cached buffer data from texture.
  34327. * It will save memory but will prevent the texture from being rebuilt
  34328. */
  34329. cleanCachedTextureBuffer(): void;
  34330. /**
  34331. * Get the world extend vectors with an optional filter
  34332. *
  34333. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34334. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34335. */
  34336. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34337. min: Vector3;
  34338. max: Vector3;
  34339. };
  34340. /**
  34341. * Creates a ray that can be used to pick in the scene
  34342. * @param x defines the x coordinate of the origin (on-screen)
  34343. * @param y defines the y coordinate of the origin (on-screen)
  34344. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34345. * @param camera defines the camera to use for the picking
  34346. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34347. * @returns a Ray
  34348. */
  34349. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34350. /**
  34351. * Creates a ray that can be used to pick in the scene
  34352. * @param x defines the x coordinate of the origin (on-screen)
  34353. * @param y defines the y coordinate of the origin (on-screen)
  34354. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34355. * @param result defines the ray where to store the picking ray
  34356. * @param camera defines the camera to use for the picking
  34357. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34358. * @returns the current scene
  34359. */
  34360. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34361. /**
  34362. * Creates a ray that can be used to pick in the scene
  34363. * @param x defines the x coordinate of the origin (on-screen)
  34364. * @param y defines the y coordinate of the origin (on-screen)
  34365. * @param camera defines the camera to use for the picking
  34366. * @returns a Ray
  34367. */
  34368. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34369. /**
  34370. * Creates a ray that can be used to pick in the scene
  34371. * @param x defines the x coordinate of the origin (on-screen)
  34372. * @param y defines the y coordinate of the origin (on-screen)
  34373. * @param result defines the ray where to store the picking ray
  34374. * @param camera defines the camera to use for the picking
  34375. * @returns the current scene
  34376. */
  34377. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34378. /** Launch a ray to try to pick a mesh in the scene
  34379. * @param x position on screen
  34380. * @param y position on screen
  34381. * @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
  34382. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34383. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34385. * @returns a PickingInfo
  34386. */
  34387. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34388. /** Use the given ray to pick a mesh in the scene
  34389. * @param ray The ray to use to pick meshes
  34390. * @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
  34391. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34392. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34393. * @returns a PickingInfo
  34394. */
  34395. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34396. /**
  34397. * Launch a ray to try to pick a mesh in the scene
  34398. * @param x X position on screen
  34399. * @param y Y position on screen
  34400. * @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
  34401. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34403. * @returns an array of PickingInfo
  34404. */
  34405. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34406. /**
  34407. * Launch a ray to try to pick a mesh in the scene
  34408. * @param ray Ray to use
  34409. * @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
  34410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34411. * @returns an array of PickingInfo
  34412. */
  34413. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34414. /**
  34415. * Force the value of meshUnderPointer
  34416. * @param mesh defines the mesh to use
  34417. */
  34418. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34419. /**
  34420. * Gets the mesh under the pointer
  34421. * @returns a Mesh or null if no mesh is under the pointer
  34422. */
  34423. getPointerOverMesh(): Nullable<AbstractMesh>;
  34424. /** @hidden */
  34425. _rebuildGeometries(): void;
  34426. /** @hidden */
  34427. _rebuildTextures(): void;
  34428. private _getByTags;
  34429. /**
  34430. * Get a list of meshes by tags
  34431. * @param tagsQuery defines the tags query to use
  34432. * @param forEach defines a predicate used to filter results
  34433. * @returns an array of Mesh
  34434. */
  34435. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34436. /**
  34437. * Get a list of cameras by tags
  34438. * @param tagsQuery defines the tags query to use
  34439. * @param forEach defines a predicate used to filter results
  34440. * @returns an array of Camera
  34441. */
  34442. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34443. /**
  34444. * Get a list of lights by tags
  34445. * @param tagsQuery defines the tags query to use
  34446. * @param forEach defines a predicate used to filter results
  34447. * @returns an array of Light
  34448. */
  34449. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34450. /**
  34451. * Get a list of materials by tags
  34452. * @param tagsQuery defines the tags query to use
  34453. * @param forEach defines a predicate used to filter results
  34454. * @returns an array of Material
  34455. */
  34456. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34457. /**
  34458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34459. * This allowed control for front to back rendering or reversly depending of the special needs.
  34460. *
  34461. * @param renderingGroupId The rendering group id corresponding to its index
  34462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34465. */
  34466. 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;
  34467. /**
  34468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34469. *
  34470. * @param renderingGroupId The rendering group id corresponding to its index
  34471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34472. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34473. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34474. */
  34475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34476. /**
  34477. * Gets the current auto clear configuration for one rendering group of the rendering
  34478. * manager.
  34479. * @param index the rendering group index to get the information for
  34480. * @returns The auto clear setup for the requested rendering group
  34481. */
  34482. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34483. private _blockMaterialDirtyMechanism;
  34484. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34485. blockMaterialDirtyMechanism: boolean;
  34486. /**
  34487. * Will flag all materials as dirty to trigger new shader compilation
  34488. * @param flag defines the flag used to specify which material part must be marked as dirty
  34489. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34490. */
  34491. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34492. /** @hidden */
  34493. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34494. /** @hidden */
  34495. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34496. }
  34497. }
  34498. declare module BABYLON {
  34499. /**
  34500. * Set of assets to keep when moving a scene into an asset container.
  34501. */
  34502. export class KeepAssets extends AbstractScene {
  34503. }
  34504. /**
  34505. * Container with a set of assets that can be added or removed from a scene.
  34506. */
  34507. export class AssetContainer extends AbstractScene {
  34508. /**
  34509. * The scene the AssetContainer belongs to.
  34510. */
  34511. scene: Scene;
  34512. /**
  34513. * Instantiates an AssetContainer.
  34514. * @param scene The scene the AssetContainer belongs to.
  34515. */
  34516. constructor(scene: Scene);
  34517. /**
  34518. * Adds all the assets from the container to the scene.
  34519. */
  34520. addAllToScene(): void;
  34521. /**
  34522. * Removes all the assets in the container from the scene
  34523. */
  34524. removeAllFromScene(): void;
  34525. /**
  34526. * Disposes all the assets in the container
  34527. */
  34528. dispose(): void;
  34529. private _moveAssets;
  34530. /**
  34531. * Removes all the assets contained in the scene and adds them to the container.
  34532. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34533. */
  34534. moveAllFromScene(keepAssets?: KeepAssets): void;
  34535. /**
  34536. * 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.
  34537. * @returns the root mesh
  34538. */
  34539. createRootMesh(): Mesh;
  34540. }
  34541. }
  34542. declare module BABYLON {
  34543. /**
  34544. * Defines how the parser contract is defined.
  34545. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34546. */
  34547. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34548. /**
  34549. * Defines how the individual parser contract is defined.
  34550. * These parser can parse an individual asset
  34551. */
  34552. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34553. /**
  34554. * Base class of the scene acting as a container for the different elements composing a scene.
  34555. * This class is dynamically extended by the different components of the scene increasing
  34556. * flexibility and reducing coupling
  34557. */
  34558. export abstract class AbstractScene {
  34559. /**
  34560. * Stores the list of available parsers in the application.
  34561. */
  34562. private static _BabylonFileParsers;
  34563. /**
  34564. * Stores the list of available individual parsers in the application.
  34565. */
  34566. private static _IndividualBabylonFileParsers;
  34567. /**
  34568. * Adds a parser in the list of available ones
  34569. * @param name Defines the name of the parser
  34570. * @param parser Defines the parser to add
  34571. */
  34572. static AddParser(name: string, parser: BabylonFileParser): void;
  34573. /**
  34574. * Gets a general parser from the list of avaialble ones
  34575. * @param name Defines the name of the parser
  34576. * @returns the requested parser or null
  34577. */
  34578. static GetParser(name: string): Nullable<BabylonFileParser>;
  34579. /**
  34580. * Adds n individual parser in the list of available ones
  34581. * @param name Defines the name of the parser
  34582. * @param parser Defines the parser to add
  34583. */
  34584. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34585. /**
  34586. * Gets an individual parser from the list of avaialble ones
  34587. * @param name Defines the name of the parser
  34588. * @returns the requested parser or null
  34589. */
  34590. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34591. /**
  34592. * Parser json data and populate both a scene and its associated container object
  34593. * @param jsonData Defines the data to parse
  34594. * @param scene Defines the scene to parse the data for
  34595. * @param container Defines the container attached to the parsing sequence
  34596. * @param rootUrl Defines the root url of the data
  34597. */
  34598. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34599. /**
  34600. * Gets the list of root nodes (ie. nodes with no parent)
  34601. */
  34602. rootNodes: Node[];
  34603. /** All of the cameras added to this scene
  34604. * @see http://doc.babylonjs.com/babylon101/cameras
  34605. */
  34606. cameras: Camera[];
  34607. /**
  34608. * All of the lights added to this scene
  34609. * @see http://doc.babylonjs.com/babylon101/lights
  34610. */
  34611. lights: Light[];
  34612. /**
  34613. * All of the (abstract) meshes added to this scene
  34614. */
  34615. meshes: AbstractMesh[];
  34616. /**
  34617. * The list of skeletons added to the scene
  34618. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34619. */
  34620. skeletons: Skeleton[];
  34621. /**
  34622. * All of the particle systems added to this scene
  34623. * @see http://doc.babylonjs.com/babylon101/particles
  34624. */
  34625. particleSystems: IParticleSystem[];
  34626. /**
  34627. * Gets a list of Animations associated with the scene
  34628. */
  34629. animations: Animation[];
  34630. /**
  34631. * All of the animation groups added to this scene
  34632. * @see http://doc.babylonjs.com/how_to/group
  34633. */
  34634. animationGroups: AnimationGroup[];
  34635. /**
  34636. * All of the multi-materials added to this scene
  34637. * @see http://doc.babylonjs.com/how_to/multi_materials
  34638. */
  34639. multiMaterials: MultiMaterial[];
  34640. /**
  34641. * All of the materials added to this scene
  34642. * In the context of a Scene, it is not supposed to be modified manually.
  34643. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34644. * Note also that the order of the Material wihin the array is not significant and might change.
  34645. * @see http://doc.babylonjs.com/babylon101/materials
  34646. */
  34647. materials: Material[];
  34648. /**
  34649. * The list of morph target managers added to the scene
  34650. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34651. */
  34652. morphTargetManagers: MorphTargetManager[];
  34653. /**
  34654. * The list of geometries used in the scene.
  34655. */
  34656. geometries: Geometry[];
  34657. /**
  34658. * All of the tranform nodes added to this scene
  34659. * In the context of a Scene, it is not supposed to be modified manually.
  34660. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34661. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34662. * @see http://doc.babylonjs.com/how_to/transformnode
  34663. */
  34664. transformNodes: TransformNode[];
  34665. /**
  34666. * ActionManagers available on the scene.
  34667. */
  34668. actionManagers: AbstractActionManager[];
  34669. /**
  34670. * Textures to keep.
  34671. */
  34672. textures: BaseTexture[];
  34673. /**
  34674. * Environment texture for the scene
  34675. */
  34676. environmentTexture: Nullable<BaseTexture>;
  34677. }
  34678. }
  34679. declare module BABYLON {
  34680. /**
  34681. * Interface used to define options for Sound class
  34682. */
  34683. export interface ISoundOptions {
  34684. /**
  34685. * Does the sound autoplay once loaded.
  34686. */
  34687. autoplay?: boolean;
  34688. /**
  34689. * Does the sound loop after it finishes playing once.
  34690. */
  34691. loop?: boolean;
  34692. /**
  34693. * Sound's volume
  34694. */
  34695. volume?: number;
  34696. /**
  34697. * Is it a spatial sound?
  34698. */
  34699. spatialSound?: boolean;
  34700. /**
  34701. * Maximum distance to hear that sound
  34702. */
  34703. maxDistance?: number;
  34704. /**
  34705. * Uses user defined attenuation function
  34706. */
  34707. useCustomAttenuation?: boolean;
  34708. /**
  34709. * Define the roll off factor of spatial sounds.
  34710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34711. */
  34712. rolloffFactor?: number;
  34713. /**
  34714. * Define the reference distance the sound should be heard perfectly.
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34716. */
  34717. refDistance?: number;
  34718. /**
  34719. * Define the distance attenuation model the sound will follow.
  34720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34721. */
  34722. distanceModel?: string;
  34723. /**
  34724. * Defines the playback speed (1 by default)
  34725. */
  34726. playbackRate?: number;
  34727. /**
  34728. * Defines if the sound is from a streaming source
  34729. */
  34730. streaming?: boolean;
  34731. /**
  34732. * Defines an optional length (in seconds) inside the sound file
  34733. */
  34734. length?: number;
  34735. /**
  34736. * Defines an optional offset (in seconds) inside the sound file
  34737. */
  34738. offset?: number;
  34739. /**
  34740. * If true, URLs will not be required to state the audio file codec to use.
  34741. */
  34742. skipCodecCheck?: boolean;
  34743. }
  34744. /**
  34745. * Defines a sound that can be played in the application.
  34746. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34748. */
  34749. export class Sound {
  34750. /**
  34751. * The name of the sound in the scene.
  34752. */
  34753. name: string;
  34754. /**
  34755. * Does the sound autoplay once loaded.
  34756. */
  34757. autoplay: boolean;
  34758. /**
  34759. * Does the sound loop after it finishes playing once.
  34760. */
  34761. loop: boolean;
  34762. /**
  34763. * Does the sound use a custom attenuation curve to simulate the falloff
  34764. * happening when the source gets further away from the camera.
  34765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34766. */
  34767. useCustomAttenuation: boolean;
  34768. /**
  34769. * The sound track id this sound belongs to.
  34770. */
  34771. soundTrackId: number;
  34772. /**
  34773. * Is this sound currently played.
  34774. */
  34775. isPlaying: boolean;
  34776. /**
  34777. * Is this sound currently paused.
  34778. */
  34779. isPaused: boolean;
  34780. /**
  34781. * Does this sound enables spatial sound.
  34782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34783. */
  34784. spatialSound: boolean;
  34785. /**
  34786. * Define the reference distance the sound should be heard perfectly.
  34787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34788. */
  34789. refDistance: number;
  34790. /**
  34791. * Define the roll off factor of spatial sounds.
  34792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34793. */
  34794. rolloffFactor: number;
  34795. /**
  34796. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34798. */
  34799. maxDistance: number;
  34800. /**
  34801. * Define the distance attenuation model the sound will follow.
  34802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34803. */
  34804. distanceModel: string;
  34805. /**
  34806. * @hidden
  34807. * Back Compat
  34808. **/
  34809. onended: () => any;
  34810. /**
  34811. * Observable event when the current playing sound finishes.
  34812. */
  34813. onEndedObservable: Observable<Sound>;
  34814. private _panningModel;
  34815. private _playbackRate;
  34816. private _streaming;
  34817. private _startTime;
  34818. private _startOffset;
  34819. private _position;
  34820. /** @hidden */
  34821. _positionInEmitterSpace: boolean;
  34822. private _localDirection;
  34823. private _volume;
  34824. private _isReadyToPlay;
  34825. private _isDirectional;
  34826. private _readyToPlayCallback;
  34827. private _audioBuffer;
  34828. private _soundSource;
  34829. private _streamingSource;
  34830. private _soundPanner;
  34831. private _soundGain;
  34832. private _inputAudioNode;
  34833. private _outputAudioNode;
  34834. private _coneInnerAngle;
  34835. private _coneOuterAngle;
  34836. private _coneOuterGain;
  34837. private _scene;
  34838. private _connectedTransformNode;
  34839. private _customAttenuationFunction;
  34840. private _registerFunc;
  34841. private _isOutputConnected;
  34842. private _htmlAudioElement;
  34843. private _urlType;
  34844. private _length?;
  34845. private _offset?;
  34846. /** @hidden */
  34847. static _SceneComponentInitialization: (scene: Scene) => void;
  34848. /**
  34849. * Create a sound and attach it to a scene
  34850. * @param name Name of your sound
  34851. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34852. * @param scene defines the scene the sound belongs to
  34853. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34854. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34855. */
  34856. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34857. /**
  34858. * Release the sound and its associated resources
  34859. */
  34860. dispose(): void;
  34861. /**
  34862. * Gets if the sounds is ready to be played or not.
  34863. * @returns true if ready, otherwise false
  34864. */
  34865. isReady(): boolean;
  34866. private _soundLoaded;
  34867. /**
  34868. * Sets the data of the sound from an audiobuffer
  34869. * @param audioBuffer The audioBuffer containing the data
  34870. */
  34871. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34872. /**
  34873. * Updates the current sounds options such as maxdistance, loop...
  34874. * @param options A JSON object containing values named as the object properties
  34875. */
  34876. updateOptions(options: ISoundOptions): void;
  34877. private _createSpatialParameters;
  34878. private _updateSpatialParameters;
  34879. /**
  34880. * Switch the panning model to HRTF:
  34881. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34883. */
  34884. switchPanningModelToHRTF(): void;
  34885. /**
  34886. * Switch the panning model to Equal Power:
  34887. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34889. */
  34890. switchPanningModelToEqualPower(): void;
  34891. private _switchPanningModel;
  34892. /**
  34893. * Connect this sound to a sound track audio node like gain...
  34894. * @param soundTrackAudioNode the sound track audio node to connect to
  34895. */
  34896. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34897. /**
  34898. * Transform this sound into a directional source
  34899. * @param coneInnerAngle Size of the inner cone in degree
  34900. * @param coneOuterAngle Size of the outer cone in degree
  34901. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34902. */
  34903. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34904. /**
  34905. * Gets or sets the inner angle for the directional cone.
  34906. */
  34907. /**
  34908. * Gets or sets the inner angle for the directional cone.
  34909. */
  34910. directionalConeInnerAngle: number;
  34911. /**
  34912. * Gets or sets the outer angle for the directional cone.
  34913. */
  34914. /**
  34915. * Gets or sets the outer angle for the directional cone.
  34916. */
  34917. directionalConeOuterAngle: number;
  34918. /**
  34919. * Sets the position of the emitter if spatial sound is enabled
  34920. * @param newPosition Defines the new posisiton
  34921. */
  34922. setPosition(newPosition: Vector3): void;
  34923. /**
  34924. * Sets the local direction of the emitter if spatial sound is enabled
  34925. * @param newLocalDirection Defines the new local direction
  34926. */
  34927. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34928. private _updateDirection;
  34929. /** @hidden */
  34930. updateDistanceFromListener(): void;
  34931. /**
  34932. * Sets a new custom attenuation function for the sound.
  34933. * @param callback Defines the function used for the attenuation
  34934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34935. */
  34936. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34937. /**
  34938. * Play the sound
  34939. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34940. * @param offset (optional) Start the sound at a specific time in seconds
  34941. * @param length (optional) Sound duration (in seconds)
  34942. */
  34943. play(time?: number, offset?: number, length?: number): void;
  34944. private _onended;
  34945. /**
  34946. * Stop the sound
  34947. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34948. */
  34949. stop(time?: number): void;
  34950. /**
  34951. * Put the sound in pause
  34952. */
  34953. pause(): void;
  34954. /**
  34955. * Sets a dedicated volume for this sounds
  34956. * @param newVolume Define the new volume of the sound
  34957. * @param time Define time for gradual change to new volume
  34958. */
  34959. setVolume(newVolume: number, time?: number): void;
  34960. /**
  34961. * Set the sound play back rate
  34962. * @param newPlaybackRate Define the playback rate the sound should be played at
  34963. */
  34964. setPlaybackRate(newPlaybackRate: number): void;
  34965. /**
  34966. * Gets the volume of the sound.
  34967. * @returns the volume of the sound
  34968. */
  34969. getVolume(): number;
  34970. /**
  34971. * Attach the sound to a dedicated mesh
  34972. * @param transformNode The transform node to connect the sound with
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34974. */
  34975. attachToMesh(transformNode: TransformNode): void;
  34976. /**
  34977. * Detach the sound from the previously attached mesh
  34978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34979. */
  34980. detachFromMesh(): void;
  34981. private _onRegisterAfterWorldMatrixUpdate;
  34982. /**
  34983. * Clone the current sound in the scene.
  34984. * @returns the new sound clone
  34985. */
  34986. clone(): Nullable<Sound>;
  34987. /**
  34988. * Gets the current underlying audio buffer containing the data
  34989. * @returns the audio buffer
  34990. */
  34991. getAudioBuffer(): Nullable<AudioBuffer>;
  34992. /**
  34993. * Serializes the Sound in a JSON representation
  34994. * @returns the JSON representation of the sound
  34995. */
  34996. serialize(): any;
  34997. /**
  34998. * Parse a JSON representation of a sound to innstantiate in a given scene
  34999. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35000. * @param scene Define the scene the new parsed sound should be created in
  35001. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35002. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35003. * @returns the newly parsed sound
  35004. */
  35005. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35006. }
  35007. }
  35008. declare module BABYLON {
  35009. /**
  35010. * This defines an action helpful to play a defined sound on a triggered action.
  35011. */
  35012. export class PlaySoundAction extends Action {
  35013. private _sound;
  35014. /**
  35015. * Instantiate the action
  35016. * @param triggerOptions defines the trigger options
  35017. * @param sound defines the sound to play
  35018. * @param condition defines the trigger related conditions
  35019. */
  35020. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35021. /** @hidden */
  35022. _prepare(): void;
  35023. /**
  35024. * Execute the action and play the sound.
  35025. */
  35026. execute(): void;
  35027. /**
  35028. * Serializes the actions and its related information.
  35029. * @param parent defines the object to serialize in
  35030. * @returns the serialized object
  35031. */
  35032. serialize(parent: any): any;
  35033. }
  35034. /**
  35035. * This defines an action helpful to stop a defined sound on a triggered action.
  35036. */
  35037. export class StopSoundAction extends Action {
  35038. private _sound;
  35039. /**
  35040. * Instantiate the action
  35041. * @param triggerOptions defines the trigger options
  35042. * @param sound defines the sound to stop
  35043. * @param condition defines the trigger related conditions
  35044. */
  35045. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35046. /** @hidden */
  35047. _prepare(): void;
  35048. /**
  35049. * Execute the action and stop the sound.
  35050. */
  35051. execute(): void;
  35052. /**
  35053. * Serializes the actions and its related information.
  35054. * @param parent defines the object to serialize in
  35055. * @returns the serialized object
  35056. */
  35057. serialize(parent: any): any;
  35058. }
  35059. }
  35060. declare module BABYLON {
  35061. /**
  35062. * This defines an action responsible to change the value of a property
  35063. * by interpolating between its current value and the newly set one once triggered.
  35064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35065. */
  35066. export class InterpolateValueAction extends Action {
  35067. /**
  35068. * Defines the path of the property where the value should be interpolated
  35069. */
  35070. propertyPath: string;
  35071. /**
  35072. * Defines the target value at the end of the interpolation.
  35073. */
  35074. value: any;
  35075. /**
  35076. * Defines the time it will take for the property to interpolate to the value.
  35077. */
  35078. duration: number;
  35079. /**
  35080. * Defines if the other scene animations should be stopped when the action has been triggered
  35081. */
  35082. stopOtherAnimations?: boolean;
  35083. /**
  35084. * Defines a callback raised once the interpolation animation has been done.
  35085. */
  35086. onInterpolationDone?: () => void;
  35087. /**
  35088. * Observable triggered once the interpolation animation has been done.
  35089. */
  35090. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35091. private _target;
  35092. private _effectiveTarget;
  35093. private _property;
  35094. /**
  35095. * Instantiate the action
  35096. * @param triggerOptions defines the trigger options
  35097. * @param target defines the object containing the value to interpolate
  35098. * @param propertyPath defines the path to the property in the target object
  35099. * @param value defines the target value at the end of the interpolation
  35100. * @param duration deines the time it will take for the property to interpolate to the value.
  35101. * @param condition defines the trigger related conditions
  35102. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35103. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35104. */
  35105. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35106. /** @hidden */
  35107. _prepare(): void;
  35108. /**
  35109. * Execute the action starts the value interpolation.
  35110. */
  35111. execute(): void;
  35112. /**
  35113. * Serializes the actions and its related information.
  35114. * @param parent defines the object to serialize in
  35115. * @returns the serialized object
  35116. */
  35117. serialize(parent: any): any;
  35118. }
  35119. }
  35120. declare module BABYLON {
  35121. /**
  35122. * Options allowed during the creation of a sound track.
  35123. */
  35124. export interface ISoundTrackOptions {
  35125. /**
  35126. * The volume the sound track should take during creation
  35127. */
  35128. volume?: number;
  35129. /**
  35130. * Define if the sound track is the main sound track of the scene
  35131. */
  35132. mainTrack?: boolean;
  35133. }
  35134. /**
  35135. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35136. * It will be also used in a future release to apply effects on a specific track.
  35137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35138. */
  35139. export class SoundTrack {
  35140. /**
  35141. * The unique identifier of the sound track in the scene.
  35142. */
  35143. id: number;
  35144. /**
  35145. * The list of sounds included in the sound track.
  35146. */
  35147. soundCollection: Array<Sound>;
  35148. private _outputAudioNode;
  35149. private _scene;
  35150. private _isMainTrack;
  35151. private _connectedAnalyser;
  35152. private _options;
  35153. private _isInitialized;
  35154. /**
  35155. * Creates a new sound track.
  35156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35157. * @param scene Define the scene the sound track belongs to
  35158. * @param options
  35159. */
  35160. constructor(scene: Scene, options?: ISoundTrackOptions);
  35161. private _initializeSoundTrackAudioGraph;
  35162. /**
  35163. * Release the sound track and its associated resources
  35164. */
  35165. dispose(): void;
  35166. /**
  35167. * Adds a sound to this sound track
  35168. * @param sound define the cound to add
  35169. * @ignoreNaming
  35170. */
  35171. AddSound(sound: Sound): void;
  35172. /**
  35173. * Removes a sound to this sound track
  35174. * @param sound define the cound to remove
  35175. * @ignoreNaming
  35176. */
  35177. RemoveSound(sound: Sound): void;
  35178. /**
  35179. * Set a global volume for the full sound track.
  35180. * @param newVolume Define the new volume of the sound track
  35181. */
  35182. setVolume(newVolume: number): void;
  35183. /**
  35184. * Switch the panning model to HRTF:
  35185. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35187. */
  35188. switchPanningModelToHRTF(): void;
  35189. /**
  35190. * Switch the panning model to Equal Power:
  35191. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35193. */
  35194. switchPanningModelToEqualPower(): void;
  35195. /**
  35196. * Connect the sound track to an audio analyser allowing some amazing
  35197. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35199. * @param analyser The analyser to connect to the engine
  35200. */
  35201. connectToAnalyser(analyser: Analyser): void;
  35202. }
  35203. }
  35204. declare module BABYLON {
  35205. interface AbstractScene {
  35206. /**
  35207. * The list of sounds used in the scene.
  35208. */
  35209. sounds: Nullable<Array<Sound>>;
  35210. }
  35211. interface Scene {
  35212. /**
  35213. * @hidden
  35214. * Backing field
  35215. */
  35216. _mainSoundTrack: SoundTrack;
  35217. /**
  35218. * The main sound track played by the scene.
  35219. * It cotains your primary collection of sounds.
  35220. */
  35221. mainSoundTrack: SoundTrack;
  35222. /**
  35223. * The list of sound tracks added to the scene
  35224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35225. */
  35226. soundTracks: Nullable<Array<SoundTrack>>;
  35227. /**
  35228. * Gets a sound using a given name
  35229. * @param name defines the name to search for
  35230. * @return the found sound or null if not found at all.
  35231. */
  35232. getSoundByName(name: string): Nullable<Sound>;
  35233. /**
  35234. * Gets or sets if audio support is enabled
  35235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35236. */
  35237. audioEnabled: boolean;
  35238. /**
  35239. * Gets or sets if audio will be output to headphones
  35240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35241. */
  35242. headphone: boolean;
  35243. /**
  35244. * Gets or sets custom audio listener position provider
  35245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35246. */
  35247. audioListenerPositionProvider: Nullable<() => Vector3>;
  35248. }
  35249. /**
  35250. * Defines the sound scene component responsible to manage any sounds
  35251. * in a given scene.
  35252. */
  35253. export class AudioSceneComponent implements ISceneSerializableComponent {
  35254. /**
  35255. * The component name helpfull to identify the component in the list of scene components.
  35256. */
  35257. readonly name: string;
  35258. /**
  35259. * The scene the component belongs to.
  35260. */
  35261. scene: Scene;
  35262. private _audioEnabled;
  35263. /**
  35264. * Gets whether audio is enabled or not.
  35265. * Please use related enable/disable method to switch state.
  35266. */
  35267. readonly audioEnabled: boolean;
  35268. private _headphone;
  35269. /**
  35270. * Gets whether audio is outputing to headphone or not.
  35271. * Please use the according Switch methods to change output.
  35272. */
  35273. readonly headphone: boolean;
  35274. private _audioListenerPositionProvider;
  35275. /**
  35276. * Gets the current audio listener position provider
  35277. */
  35278. /**
  35279. * Sets a custom listener position for all sounds in the scene
  35280. * By default, this is the position of the first active camera
  35281. */
  35282. audioListenerPositionProvider: Nullable<() => Vector3>;
  35283. /**
  35284. * Creates a new instance of the component for the given scene
  35285. * @param scene Defines the scene to register the component in
  35286. */
  35287. constructor(scene: Scene);
  35288. /**
  35289. * Registers the component in a given scene
  35290. */
  35291. register(): void;
  35292. /**
  35293. * Rebuilds the elements related to this component in case of
  35294. * context lost for instance.
  35295. */
  35296. rebuild(): void;
  35297. /**
  35298. * Serializes the component data to the specified json object
  35299. * @param serializationObject The object to serialize to
  35300. */
  35301. serialize(serializationObject: any): void;
  35302. /**
  35303. * Adds all the elements from the container to the scene
  35304. * @param container the container holding the elements
  35305. */
  35306. addFromContainer(container: AbstractScene): void;
  35307. /**
  35308. * Removes all the elements in the container from the scene
  35309. * @param container contains the elements to remove
  35310. * @param dispose if the removed element should be disposed (default: false)
  35311. */
  35312. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35313. /**
  35314. * Disposes the component and the associated ressources.
  35315. */
  35316. dispose(): void;
  35317. /**
  35318. * Disables audio in the associated scene.
  35319. */
  35320. disableAudio(): void;
  35321. /**
  35322. * Enables audio in the associated scene.
  35323. */
  35324. enableAudio(): void;
  35325. /**
  35326. * Switch audio to headphone output.
  35327. */
  35328. switchAudioModeForHeadphones(): void;
  35329. /**
  35330. * Switch audio to normal speakers.
  35331. */
  35332. switchAudioModeForNormalSpeakers(): void;
  35333. private _afterRender;
  35334. }
  35335. }
  35336. declare module BABYLON {
  35337. /**
  35338. * Wraps one or more Sound objects and selects one with random weight for playback.
  35339. */
  35340. export class WeightedSound {
  35341. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35342. loop: boolean;
  35343. private _coneInnerAngle;
  35344. private _coneOuterAngle;
  35345. private _volume;
  35346. /** A Sound is currently playing. */
  35347. isPlaying: boolean;
  35348. /** A Sound is currently paused. */
  35349. isPaused: boolean;
  35350. private _sounds;
  35351. private _weights;
  35352. private _currentIndex?;
  35353. /**
  35354. * Creates a new WeightedSound from the list of sounds given.
  35355. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35356. * @param sounds Array of Sounds that will be selected from.
  35357. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35358. */
  35359. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35360. /**
  35361. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35362. */
  35363. /**
  35364. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35365. */
  35366. directionalConeInnerAngle: number;
  35367. /**
  35368. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35369. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35370. */
  35371. /**
  35372. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35373. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35374. */
  35375. directionalConeOuterAngle: number;
  35376. /**
  35377. * Playback volume.
  35378. */
  35379. /**
  35380. * Playback volume.
  35381. */
  35382. volume: number;
  35383. private _onended;
  35384. /**
  35385. * Suspend playback
  35386. */
  35387. pause(): void;
  35388. /**
  35389. * Stop playback
  35390. */
  35391. stop(): void;
  35392. /**
  35393. * Start playback.
  35394. * @param startOffset Position the clip head at a specific time in seconds.
  35395. */
  35396. play(startOffset?: number): void;
  35397. }
  35398. }
  35399. declare module BABYLON {
  35400. /**
  35401. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35403. */
  35404. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35405. /**
  35406. * Gets the name of the behavior.
  35407. */
  35408. readonly name: string;
  35409. /**
  35410. * The easing function used by animations
  35411. */
  35412. static EasingFunction: BackEase;
  35413. /**
  35414. * The easing mode used by animations
  35415. */
  35416. static EasingMode: number;
  35417. /**
  35418. * The duration of the animation, in milliseconds
  35419. */
  35420. transitionDuration: number;
  35421. /**
  35422. * Length of the distance animated by the transition when lower radius is reached
  35423. */
  35424. lowerRadiusTransitionRange: number;
  35425. /**
  35426. * Length of the distance animated by the transition when upper radius is reached
  35427. */
  35428. upperRadiusTransitionRange: number;
  35429. private _autoTransitionRange;
  35430. /**
  35431. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35432. */
  35433. /**
  35434. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35435. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35436. */
  35437. autoTransitionRange: boolean;
  35438. private _attachedCamera;
  35439. private _onAfterCheckInputsObserver;
  35440. private _onMeshTargetChangedObserver;
  35441. /**
  35442. * Initializes the behavior.
  35443. */
  35444. init(): void;
  35445. /**
  35446. * Attaches the behavior to its arc rotate camera.
  35447. * @param camera Defines the camera to attach the behavior to
  35448. */
  35449. attach(camera: ArcRotateCamera): void;
  35450. /**
  35451. * Detaches the behavior from its current arc rotate camera.
  35452. */
  35453. detach(): void;
  35454. private _radiusIsAnimating;
  35455. private _radiusBounceTransition;
  35456. private _animatables;
  35457. private _cachedWheelPrecision;
  35458. /**
  35459. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35460. * @param radiusLimit The limit to check against.
  35461. * @return Bool to indicate if at limit.
  35462. */
  35463. private _isRadiusAtLimit;
  35464. /**
  35465. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35466. * @param radiusDelta The delta by which to animate to. Can be negative.
  35467. */
  35468. private _applyBoundRadiusAnimation;
  35469. /**
  35470. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35471. */
  35472. protected _clearAnimationLocks(): void;
  35473. /**
  35474. * Stops and removes all animations that have been applied to the camera
  35475. */
  35476. stopAllAnimations(): void;
  35477. }
  35478. }
  35479. declare module BABYLON {
  35480. /**
  35481. * 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.
  35482. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35483. */
  35484. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35485. /**
  35486. * Gets the name of the behavior.
  35487. */
  35488. readonly name: string;
  35489. private _mode;
  35490. private _radiusScale;
  35491. private _positionScale;
  35492. private _defaultElevation;
  35493. private _elevationReturnTime;
  35494. private _elevationReturnWaitTime;
  35495. private _zoomStopsAnimation;
  35496. private _framingTime;
  35497. /**
  35498. * The easing function used by animations
  35499. */
  35500. static EasingFunction: ExponentialEase;
  35501. /**
  35502. * The easing mode used by animations
  35503. */
  35504. static EasingMode: number;
  35505. /**
  35506. * Sets the current mode used by the behavior
  35507. */
  35508. /**
  35509. * Gets current mode used by the behavior.
  35510. */
  35511. mode: number;
  35512. /**
  35513. * Sets the scale applied to the radius (1 by default)
  35514. */
  35515. /**
  35516. * Gets the scale applied to the radius
  35517. */
  35518. radiusScale: number;
  35519. /**
  35520. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35521. */
  35522. /**
  35523. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35524. */
  35525. positionScale: number;
  35526. /**
  35527. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35528. * behaviour is triggered, in radians.
  35529. */
  35530. /**
  35531. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35532. * behaviour is triggered, in radians.
  35533. */
  35534. defaultElevation: number;
  35535. /**
  35536. * Sets the time (in milliseconds) taken to return to the default beta position.
  35537. * Negative value indicates camera should not return to default.
  35538. */
  35539. /**
  35540. * Gets the time (in milliseconds) taken to return to the default beta position.
  35541. * Negative value indicates camera should not return to default.
  35542. */
  35543. elevationReturnTime: number;
  35544. /**
  35545. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35546. */
  35547. /**
  35548. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35549. */
  35550. elevationReturnWaitTime: number;
  35551. /**
  35552. * Sets the flag that indicates if user zooming should stop animation.
  35553. */
  35554. /**
  35555. * Gets the flag that indicates if user zooming should stop animation.
  35556. */
  35557. zoomStopsAnimation: boolean;
  35558. /**
  35559. * Sets the transition time when framing the mesh, in milliseconds
  35560. */
  35561. /**
  35562. * Gets the transition time when framing the mesh, in milliseconds
  35563. */
  35564. framingTime: number;
  35565. /**
  35566. * Define if the behavior should automatically change the configured
  35567. * camera limits and sensibilities.
  35568. */
  35569. autoCorrectCameraLimitsAndSensibility: boolean;
  35570. private _onPrePointerObservableObserver;
  35571. private _onAfterCheckInputsObserver;
  35572. private _onMeshTargetChangedObserver;
  35573. private _attachedCamera;
  35574. private _isPointerDown;
  35575. private _lastInteractionTime;
  35576. /**
  35577. * Initializes the behavior.
  35578. */
  35579. init(): void;
  35580. /**
  35581. * Attaches the behavior to its arc rotate camera.
  35582. * @param camera Defines the camera to attach the behavior to
  35583. */
  35584. attach(camera: ArcRotateCamera): void;
  35585. /**
  35586. * Detaches the behavior from its current arc rotate camera.
  35587. */
  35588. detach(): void;
  35589. private _animatables;
  35590. private _betaIsAnimating;
  35591. private _betaTransition;
  35592. private _radiusTransition;
  35593. private _vectorTransition;
  35594. /**
  35595. * Targets the given mesh and updates zoom level accordingly.
  35596. * @param mesh The mesh to target.
  35597. * @param radius Optional. If a cached radius position already exists, overrides default.
  35598. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35599. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35600. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35601. */
  35602. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35603. /**
  35604. * Targets the given mesh with its children and updates zoom level accordingly.
  35605. * @param mesh The mesh to target.
  35606. * @param radius Optional. If a cached radius position already exists, overrides default.
  35607. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35608. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35609. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35610. */
  35611. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35612. /**
  35613. * Targets the given meshes with their children and updates zoom level accordingly.
  35614. * @param meshes The mesh to target.
  35615. * @param radius Optional. If a cached radius position already exists, overrides default.
  35616. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35617. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35618. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35619. */
  35620. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35621. /**
  35622. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35623. * @param minimumWorld Determines the smaller position of the bounding box extend
  35624. * @param maximumWorld Determines the bigger position of the bounding box extend
  35625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35627. */
  35628. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35629. /**
  35630. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35631. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35632. * frustum width.
  35633. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35634. * to fully enclose the mesh in the viewing frustum.
  35635. */
  35636. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35637. /**
  35638. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35639. * is automatically returned to its default position (expected to be above ground plane).
  35640. */
  35641. private _maintainCameraAboveGround;
  35642. /**
  35643. * Returns the frustum slope based on the canvas ratio and camera FOV
  35644. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35645. */
  35646. private _getFrustumSlope;
  35647. /**
  35648. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35649. */
  35650. private _clearAnimationLocks;
  35651. /**
  35652. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35653. */
  35654. private _applyUserInteraction;
  35655. /**
  35656. * Stops and removes all animations that have been applied to the camera
  35657. */
  35658. stopAllAnimations(): void;
  35659. /**
  35660. * Gets a value indicating if the user is moving the camera
  35661. */
  35662. readonly isUserIsMoving: boolean;
  35663. /**
  35664. * The camera can move all the way towards the mesh.
  35665. */
  35666. static IgnoreBoundsSizeMode: number;
  35667. /**
  35668. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35669. */
  35670. static FitFrustumSidesMode: number;
  35671. }
  35672. }
  35673. declare module BABYLON {
  35674. /**
  35675. * Base class for Camera Pointer Inputs.
  35676. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35677. * for example usage.
  35678. */
  35679. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35680. /**
  35681. * Defines the camera the input is attached to.
  35682. */
  35683. abstract camera: Camera;
  35684. /**
  35685. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35686. */
  35687. protected _altKey: boolean;
  35688. protected _ctrlKey: boolean;
  35689. protected _metaKey: boolean;
  35690. protected _shiftKey: boolean;
  35691. /**
  35692. * Which mouse buttons were pressed at time of last mouse event.
  35693. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35694. */
  35695. protected _buttonsPressed: number;
  35696. /**
  35697. * Defines the buttons associated with the input to handle camera move.
  35698. */
  35699. buttons: number[];
  35700. /**
  35701. * Attach the input controls to a specific dom element to get the input from.
  35702. * @param element Defines the element the controls should be listened from
  35703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35704. */
  35705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35706. /**
  35707. * Detach the current controls from the specified dom element.
  35708. * @param element Defines the element to stop listening the inputs from
  35709. */
  35710. detachControl(element: Nullable<HTMLElement>): void;
  35711. /**
  35712. * Gets the class name of the current input.
  35713. * @returns the class name
  35714. */
  35715. getClassName(): string;
  35716. /**
  35717. * Get the friendly name associated with the input class.
  35718. * @returns the input friendly name
  35719. */
  35720. getSimpleName(): string;
  35721. /**
  35722. * Called on pointer POINTERDOUBLETAP event.
  35723. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35724. */
  35725. protected onDoubleTap(type: string): void;
  35726. /**
  35727. * Called on pointer POINTERMOVE event if only a single touch is active.
  35728. * Override this method to provide functionality.
  35729. */
  35730. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35731. /**
  35732. * Called on pointer POINTERMOVE event if multiple touches are active.
  35733. * Override this method to provide functionality.
  35734. */
  35735. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35736. /**
  35737. * Called on JS contextmenu event.
  35738. * Override this method to provide functionality.
  35739. */
  35740. protected onContextMenu(evt: PointerEvent): void;
  35741. /**
  35742. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35743. * press.
  35744. * Override this method to provide functionality.
  35745. */
  35746. protected onButtonDown(evt: PointerEvent): void;
  35747. /**
  35748. * Called each time a new POINTERUP event occurs. Ie, for each button
  35749. * release.
  35750. * Override this method to provide functionality.
  35751. */
  35752. protected onButtonUp(evt: PointerEvent): void;
  35753. /**
  35754. * Called when window becomes inactive.
  35755. * Override this method to provide functionality.
  35756. */
  35757. protected onLostFocus(): void;
  35758. private _pointerInput;
  35759. private _observer;
  35760. private _onLostFocus;
  35761. private pointA;
  35762. private pointB;
  35763. }
  35764. }
  35765. declare module BABYLON {
  35766. /**
  35767. * Manage the pointers inputs to control an arc rotate camera.
  35768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35769. */
  35770. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35771. /**
  35772. * Defines the camera the input is attached to.
  35773. */
  35774. camera: ArcRotateCamera;
  35775. /**
  35776. * Gets the class name of the current input.
  35777. * @returns the class name
  35778. */
  35779. getClassName(): string;
  35780. /**
  35781. * Defines the buttons associated with the input to handle camera move.
  35782. */
  35783. buttons: number[];
  35784. /**
  35785. * Defines the pointer angular sensibility along the X axis or how fast is
  35786. * the camera rotating.
  35787. */
  35788. angularSensibilityX: number;
  35789. /**
  35790. * Defines the pointer angular sensibility along the Y axis or how fast is
  35791. * the camera rotating.
  35792. */
  35793. angularSensibilityY: number;
  35794. /**
  35795. * Defines the pointer pinch precision or how fast is the camera zooming.
  35796. */
  35797. pinchPrecision: number;
  35798. /**
  35799. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35800. * from 0.
  35801. * It defines the percentage of current camera.radius to use as delta when
  35802. * pinch zoom is used.
  35803. */
  35804. pinchDeltaPercentage: number;
  35805. /**
  35806. * Defines the pointer panning sensibility or how fast is the camera moving.
  35807. */
  35808. panningSensibility: number;
  35809. /**
  35810. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35811. */
  35812. multiTouchPanning: boolean;
  35813. /**
  35814. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35815. * zoom (pinch) through multitouch.
  35816. */
  35817. multiTouchPanAndZoom: boolean;
  35818. /**
  35819. * Revers pinch action direction.
  35820. */
  35821. pinchInwards: boolean;
  35822. private _isPanClick;
  35823. private _twoFingerActivityCount;
  35824. private _isPinching;
  35825. /**
  35826. * Called on pointer POINTERMOVE event if only a single touch is active.
  35827. */
  35828. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35829. /**
  35830. * Called on pointer POINTERDOUBLETAP event.
  35831. */
  35832. protected onDoubleTap(type: string): void;
  35833. /**
  35834. * Called on pointer POINTERMOVE event if multiple touches are active.
  35835. */
  35836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35837. /**
  35838. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35839. * press.
  35840. */
  35841. protected onButtonDown(evt: PointerEvent): void;
  35842. /**
  35843. * Called each time a new POINTERUP event occurs. Ie, for each button
  35844. * release.
  35845. */
  35846. protected onButtonUp(evt: PointerEvent): void;
  35847. /**
  35848. * Called when window becomes inactive.
  35849. */
  35850. protected onLostFocus(): void;
  35851. }
  35852. }
  35853. declare module BABYLON {
  35854. /**
  35855. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35857. */
  35858. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35859. /**
  35860. * Defines the camera the input is attached to.
  35861. */
  35862. camera: ArcRotateCamera;
  35863. /**
  35864. * Defines the list of key codes associated with the up action (increase alpha)
  35865. */
  35866. keysUp: number[];
  35867. /**
  35868. * Defines the list of key codes associated with the down action (decrease alpha)
  35869. */
  35870. keysDown: number[];
  35871. /**
  35872. * Defines the list of key codes associated with the left action (increase beta)
  35873. */
  35874. keysLeft: number[];
  35875. /**
  35876. * Defines the list of key codes associated with the right action (decrease beta)
  35877. */
  35878. keysRight: number[];
  35879. /**
  35880. * Defines the list of key codes associated with the reset action.
  35881. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35882. */
  35883. keysReset: number[];
  35884. /**
  35885. * Defines the panning sensibility of the inputs.
  35886. * (How fast is the camera paning)
  35887. */
  35888. panningSensibility: number;
  35889. /**
  35890. * Defines the zooming sensibility of the inputs.
  35891. * (How fast is the camera zooming)
  35892. */
  35893. zoomingSensibility: number;
  35894. /**
  35895. * Defines wether maintaining the alt key down switch the movement mode from
  35896. * orientation to zoom.
  35897. */
  35898. useAltToZoom: boolean;
  35899. /**
  35900. * Rotation speed of the camera
  35901. */
  35902. angularSpeed: number;
  35903. private _keys;
  35904. private _ctrlPressed;
  35905. private _altPressed;
  35906. private _onCanvasBlurObserver;
  35907. private _onKeyboardObserver;
  35908. private _engine;
  35909. private _scene;
  35910. /**
  35911. * Attach the input controls to a specific dom element to get the input from.
  35912. * @param element Defines the element the controls should be listened from
  35913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35914. */
  35915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35916. /**
  35917. * Detach the current controls from the specified dom element.
  35918. * @param element Defines the element to stop listening the inputs from
  35919. */
  35920. detachControl(element: Nullable<HTMLElement>): void;
  35921. /**
  35922. * Update the current camera state depending on the inputs that have been used this frame.
  35923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35924. */
  35925. checkInputs(): void;
  35926. /**
  35927. * Gets the class name of the current intput.
  35928. * @returns the class name
  35929. */
  35930. getClassName(): string;
  35931. /**
  35932. * Get the friendly name associated with the input class.
  35933. * @returns the input friendly name
  35934. */
  35935. getSimpleName(): string;
  35936. }
  35937. }
  35938. declare module BABYLON {
  35939. /**
  35940. * Manage the mouse wheel inputs to control an arc rotate camera.
  35941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35942. */
  35943. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35944. /**
  35945. * Defines the camera the input is attached to.
  35946. */
  35947. camera: ArcRotateCamera;
  35948. /**
  35949. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35950. */
  35951. wheelPrecision: number;
  35952. /**
  35953. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35954. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35955. */
  35956. wheelDeltaPercentage: number;
  35957. private _wheel;
  35958. private _observer;
  35959. private computeDeltaFromMouseWheelLegacyEvent;
  35960. /**
  35961. * Attach the input controls to a specific dom element to get the input from.
  35962. * @param element Defines the element the controls should be listened from
  35963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35964. */
  35965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35966. /**
  35967. * Detach the current controls from the specified dom element.
  35968. * @param element Defines the element to stop listening the inputs from
  35969. */
  35970. detachControl(element: Nullable<HTMLElement>): void;
  35971. /**
  35972. * Gets the class name of the current intput.
  35973. * @returns the class name
  35974. */
  35975. getClassName(): string;
  35976. /**
  35977. * Get the friendly name associated with the input class.
  35978. * @returns the input friendly name
  35979. */
  35980. getSimpleName(): string;
  35981. }
  35982. }
  35983. declare module BABYLON {
  35984. /**
  35985. * Default Inputs manager for the ArcRotateCamera.
  35986. * It groups all the default supported inputs for ease of use.
  35987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35988. */
  35989. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35990. /**
  35991. * Instantiates a new ArcRotateCameraInputsManager.
  35992. * @param camera Defines the camera the inputs belong to
  35993. */
  35994. constructor(camera: ArcRotateCamera);
  35995. /**
  35996. * Add mouse wheel input support to the input manager.
  35997. * @returns the current input manager
  35998. */
  35999. addMouseWheel(): ArcRotateCameraInputsManager;
  36000. /**
  36001. * Add pointers input support to the input manager.
  36002. * @returns the current input manager
  36003. */
  36004. addPointers(): ArcRotateCameraInputsManager;
  36005. /**
  36006. * Add keyboard input support to the input manager.
  36007. * @returns the current input manager
  36008. */
  36009. addKeyboard(): ArcRotateCameraInputsManager;
  36010. }
  36011. }
  36012. declare module BABYLON {
  36013. /**
  36014. * This represents an orbital type of camera.
  36015. *
  36016. * 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.
  36017. * 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.
  36018. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36019. */
  36020. export class ArcRotateCamera extends TargetCamera {
  36021. /**
  36022. * Defines the rotation angle of the camera along the longitudinal axis.
  36023. */
  36024. alpha: number;
  36025. /**
  36026. * Defines the rotation angle of the camera along the latitudinal axis.
  36027. */
  36028. beta: number;
  36029. /**
  36030. * Defines the radius of the camera from it s target point.
  36031. */
  36032. radius: number;
  36033. protected _target: Vector3;
  36034. protected _targetHost: Nullable<AbstractMesh>;
  36035. /**
  36036. * Defines the target point of the camera.
  36037. * The camera looks towards it form the radius distance.
  36038. */
  36039. target: Vector3;
  36040. /**
  36041. * Define the current local position of the camera in the scene
  36042. */
  36043. position: Vector3;
  36044. protected _upVector: Vector3;
  36045. protected _upToYMatrix: Matrix;
  36046. protected _YToUpMatrix: Matrix;
  36047. /**
  36048. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36049. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36050. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36051. */
  36052. upVector: Vector3;
  36053. /**
  36054. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36055. */
  36056. setMatUp(): void;
  36057. /**
  36058. * Current inertia value on the longitudinal axis.
  36059. * The bigger this number the longer it will take for the camera to stop.
  36060. */
  36061. inertialAlphaOffset: number;
  36062. /**
  36063. * Current inertia value on the latitudinal axis.
  36064. * The bigger this number the longer it will take for the camera to stop.
  36065. */
  36066. inertialBetaOffset: number;
  36067. /**
  36068. * Current inertia value on the radius axis.
  36069. * The bigger this number the longer it will take for the camera to stop.
  36070. */
  36071. inertialRadiusOffset: number;
  36072. /**
  36073. * Minimum allowed angle on the longitudinal axis.
  36074. * This can help limiting how the Camera is able to move in the scene.
  36075. */
  36076. lowerAlphaLimit: Nullable<number>;
  36077. /**
  36078. * Maximum allowed angle on the longitudinal axis.
  36079. * This can help limiting how the Camera is able to move in the scene.
  36080. */
  36081. upperAlphaLimit: Nullable<number>;
  36082. /**
  36083. * Minimum allowed angle on the latitudinal axis.
  36084. * This can help limiting how the Camera is able to move in the scene.
  36085. */
  36086. lowerBetaLimit: number;
  36087. /**
  36088. * Maximum allowed angle on the latitudinal axis.
  36089. * This can help limiting how the Camera is able to move in the scene.
  36090. */
  36091. upperBetaLimit: number;
  36092. /**
  36093. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36094. * This can help limiting how the Camera is able to move in the scene.
  36095. */
  36096. lowerRadiusLimit: Nullable<number>;
  36097. /**
  36098. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36099. * This can help limiting how the Camera is able to move in the scene.
  36100. */
  36101. upperRadiusLimit: Nullable<number>;
  36102. /**
  36103. * Defines the current inertia value used during panning of the camera along the X axis.
  36104. */
  36105. inertialPanningX: number;
  36106. /**
  36107. * Defines the current inertia value used during panning of the camera along the Y axis.
  36108. */
  36109. inertialPanningY: number;
  36110. /**
  36111. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36112. * Basically if your fingers moves away from more than this distance you will be considered
  36113. * in pinch mode.
  36114. */
  36115. pinchToPanMaxDistance: number;
  36116. /**
  36117. * Defines the maximum distance the camera can pan.
  36118. * This could help keeping the cammera always in your scene.
  36119. */
  36120. panningDistanceLimit: Nullable<number>;
  36121. /**
  36122. * Defines the target of the camera before paning.
  36123. */
  36124. panningOriginTarget: Vector3;
  36125. /**
  36126. * Defines the value of the inertia used during panning.
  36127. * 0 would mean stop inertia and one would mean no decelleration at all.
  36128. */
  36129. panningInertia: number;
  36130. /**
  36131. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36132. */
  36133. angularSensibilityX: number;
  36134. /**
  36135. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36136. */
  36137. angularSensibilityY: number;
  36138. /**
  36139. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36140. */
  36141. pinchPrecision: number;
  36142. /**
  36143. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36144. * It will be used instead of pinchDeltaPrecision if different from 0.
  36145. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36146. */
  36147. pinchDeltaPercentage: number;
  36148. /**
  36149. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36150. */
  36151. panningSensibility: number;
  36152. /**
  36153. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36154. */
  36155. keysUp: number[];
  36156. /**
  36157. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36158. */
  36159. keysDown: number[];
  36160. /**
  36161. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36162. */
  36163. keysLeft: number[];
  36164. /**
  36165. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36166. */
  36167. keysRight: number[];
  36168. /**
  36169. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36170. */
  36171. wheelPrecision: number;
  36172. /**
  36173. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36174. * It will be used instead of pinchDeltaPrecision if different from 0.
  36175. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36176. */
  36177. wheelDeltaPercentage: number;
  36178. /**
  36179. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36180. */
  36181. zoomOnFactor: number;
  36182. /**
  36183. * Defines a screen offset for the camera position.
  36184. */
  36185. targetScreenOffset: Vector2;
  36186. /**
  36187. * Allows the camera to be completely reversed.
  36188. * If false the camera can not arrive upside down.
  36189. */
  36190. allowUpsideDown: boolean;
  36191. /**
  36192. * Define if double tap/click is used to restore the previously saved state of the camera.
  36193. */
  36194. useInputToRestoreState: boolean;
  36195. /** @hidden */
  36196. _viewMatrix: Matrix;
  36197. /** @hidden */
  36198. _useCtrlForPanning: boolean;
  36199. /** @hidden */
  36200. _panningMouseButton: number;
  36201. /**
  36202. * Defines the input associated to the camera.
  36203. */
  36204. inputs: ArcRotateCameraInputsManager;
  36205. /** @hidden */
  36206. _reset: () => void;
  36207. /**
  36208. * Defines the allowed panning axis.
  36209. */
  36210. panningAxis: Vector3;
  36211. protected _localDirection: Vector3;
  36212. protected _transformedDirection: Vector3;
  36213. private _bouncingBehavior;
  36214. /**
  36215. * Gets the bouncing behavior of the camera if it has been enabled.
  36216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36217. */
  36218. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36219. /**
  36220. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36222. */
  36223. useBouncingBehavior: boolean;
  36224. private _framingBehavior;
  36225. /**
  36226. * Gets the framing behavior of the camera if it has been enabled.
  36227. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36228. */
  36229. readonly framingBehavior: Nullable<FramingBehavior>;
  36230. /**
  36231. * Defines if the framing behavior of the camera is enabled on the camera.
  36232. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36233. */
  36234. useFramingBehavior: boolean;
  36235. private _autoRotationBehavior;
  36236. /**
  36237. * Gets the auto rotation behavior of the camera if it has been enabled.
  36238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36239. */
  36240. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36241. /**
  36242. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36243. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36244. */
  36245. useAutoRotationBehavior: boolean;
  36246. /**
  36247. * Observable triggered when the mesh target has been changed on the camera.
  36248. */
  36249. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36250. /**
  36251. * Event raised when the camera is colliding with a mesh.
  36252. */
  36253. onCollide: (collidedMesh: AbstractMesh) => void;
  36254. /**
  36255. * Defines whether the camera should check collision with the objects oh the scene.
  36256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36257. */
  36258. checkCollisions: boolean;
  36259. /**
  36260. * Defines the collision radius of the camera.
  36261. * This simulates a sphere around the camera.
  36262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36263. */
  36264. collisionRadius: Vector3;
  36265. protected _collider: Collider;
  36266. protected _previousPosition: Vector3;
  36267. protected _collisionVelocity: Vector3;
  36268. protected _newPosition: Vector3;
  36269. protected _previousAlpha: number;
  36270. protected _previousBeta: number;
  36271. protected _previousRadius: number;
  36272. protected _collisionTriggered: boolean;
  36273. protected _targetBoundingCenter: Nullable<Vector3>;
  36274. private _computationVector;
  36275. /**
  36276. * Instantiates a new ArcRotateCamera in a given scene
  36277. * @param name Defines the name of the camera
  36278. * @param alpha Defines the camera rotation along the logitudinal axis
  36279. * @param beta Defines the camera rotation along the latitudinal axis
  36280. * @param radius Defines the camera distance from its target
  36281. * @param target Defines the camera target
  36282. * @param scene Defines the scene the camera belongs to
  36283. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36284. */
  36285. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36286. /** @hidden */
  36287. _initCache(): void;
  36288. /** @hidden */
  36289. _updateCache(ignoreParentClass?: boolean): void;
  36290. protected _getTargetPosition(): Vector3;
  36291. private _storedAlpha;
  36292. private _storedBeta;
  36293. private _storedRadius;
  36294. private _storedTarget;
  36295. private _storedTargetScreenOffset;
  36296. /**
  36297. * Stores the current state of the camera (alpha, beta, radius and target)
  36298. * @returns the camera itself
  36299. */
  36300. storeState(): Camera;
  36301. /**
  36302. * @hidden
  36303. * Restored camera state. You must call storeState() first
  36304. */
  36305. _restoreStateValues(): boolean;
  36306. /** @hidden */
  36307. _isSynchronizedViewMatrix(): boolean;
  36308. /**
  36309. * Attached controls to the current camera.
  36310. * @param element Defines the element the controls should be listened from
  36311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36312. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36313. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36314. */
  36315. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36316. /**
  36317. * Detach the current controls from the camera.
  36318. * The camera will stop reacting to inputs.
  36319. * @param element Defines the element to stop listening the inputs from
  36320. */
  36321. detachControl(element: HTMLElement): void;
  36322. /** @hidden */
  36323. _checkInputs(): void;
  36324. protected _checkLimits(): void;
  36325. /**
  36326. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36327. */
  36328. rebuildAnglesAndRadius(): void;
  36329. /**
  36330. * Use a position to define the current camera related information like aplha, beta and radius
  36331. * @param position Defines the position to set the camera at
  36332. */
  36333. setPosition(position: Vector3): void;
  36334. /**
  36335. * Defines the target the camera should look at.
  36336. * This will automatically adapt alpha beta and radius to fit within the new target.
  36337. * @param target Defines the new target as a Vector or a mesh
  36338. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36339. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36340. */
  36341. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36342. /** @hidden */
  36343. _getViewMatrix(): Matrix;
  36344. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36345. /**
  36346. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36347. * @param meshes Defines the mesh to zoom on
  36348. * @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)
  36349. */
  36350. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36351. /**
  36352. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36353. * The target will be changed but the radius
  36354. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36355. * @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)
  36356. */
  36357. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36358. min: Vector3;
  36359. max: Vector3;
  36360. distance: number;
  36361. }, doNotUpdateMaxZ?: boolean): void;
  36362. /**
  36363. * @override
  36364. * Override Camera.createRigCamera
  36365. */
  36366. createRigCamera(name: string, cameraIndex: number): Camera;
  36367. /**
  36368. * @hidden
  36369. * @override
  36370. * Override Camera._updateRigCameras
  36371. */
  36372. _updateRigCameras(): void;
  36373. /**
  36374. * Destroy the camera and release the current resources hold by it.
  36375. */
  36376. dispose(): void;
  36377. /**
  36378. * Gets the current object class name.
  36379. * @return the class name
  36380. */
  36381. getClassName(): string;
  36382. }
  36383. }
  36384. declare module BABYLON {
  36385. /**
  36386. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36387. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36388. */
  36389. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36390. /**
  36391. * Gets the name of the behavior.
  36392. */
  36393. readonly name: string;
  36394. private _zoomStopsAnimation;
  36395. private _idleRotationSpeed;
  36396. private _idleRotationWaitTime;
  36397. private _idleRotationSpinupTime;
  36398. /**
  36399. * Sets the flag that indicates if user zooming should stop animation.
  36400. */
  36401. /**
  36402. * Gets the flag that indicates if user zooming should stop animation.
  36403. */
  36404. zoomStopsAnimation: boolean;
  36405. /**
  36406. * Sets the default speed at which the camera rotates around the model.
  36407. */
  36408. /**
  36409. * Gets the default speed at which the camera rotates around the model.
  36410. */
  36411. idleRotationSpeed: number;
  36412. /**
  36413. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36414. */
  36415. /**
  36416. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36417. */
  36418. idleRotationWaitTime: number;
  36419. /**
  36420. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36421. */
  36422. /**
  36423. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36424. */
  36425. idleRotationSpinupTime: number;
  36426. /**
  36427. * Gets a value indicating if the camera is currently rotating because of this behavior
  36428. */
  36429. readonly rotationInProgress: boolean;
  36430. private _onPrePointerObservableObserver;
  36431. private _onAfterCheckInputsObserver;
  36432. private _attachedCamera;
  36433. private _isPointerDown;
  36434. private _lastFrameTime;
  36435. private _lastInteractionTime;
  36436. private _cameraRotationSpeed;
  36437. /**
  36438. * Initializes the behavior.
  36439. */
  36440. init(): void;
  36441. /**
  36442. * Attaches the behavior to its arc rotate camera.
  36443. * @param camera Defines the camera to attach the behavior to
  36444. */
  36445. attach(camera: ArcRotateCamera): void;
  36446. /**
  36447. * Detaches the behavior from its current arc rotate camera.
  36448. */
  36449. detach(): void;
  36450. /**
  36451. * Returns true if user is scrolling.
  36452. * @return true if user is scrolling.
  36453. */
  36454. private _userIsZooming;
  36455. private _lastFrameRadius;
  36456. private _shouldAnimationStopForInteraction;
  36457. /**
  36458. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36459. */
  36460. private _applyUserInteraction;
  36461. private _userIsMoving;
  36462. }
  36463. }
  36464. declare module BABYLON {
  36465. /**
  36466. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36467. */
  36468. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36469. private ui;
  36470. /**
  36471. * The name of the behavior
  36472. */
  36473. name: string;
  36474. /**
  36475. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36476. */
  36477. distanceAwayFromFace: number;
  36478. /**
  36479. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36480. */
  36481. distanceAwayFromBottomOfFace: number;
  36482. private _faceVectors;
  36483. private _target;
  36484. private _scene;
  36485. private _onRenderObserver;
  36486. private _tmpMatrix;
  36487. private _tmpVector;
  36488. /**
  36489. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36490. * @param ui The transform node that should be attched to the mesh
  36491. */
  36492. constructor(ui: TransformNode);
  36493. /**
  36494. * Initializes the behavior
  36495. */
  36496. init(): void;
  36497. private _closestFace;
  36498. private _zeroVector;
  36499. private _lookAtTmpMatrix;
  36500. private _lookAtToRef;
  36501. /**
  36502. * Attaches the AttachToBoxBehavior to the passed in mesh
  36503. * @param target The mesh that the specified node will be attached to
  36504. */
  36505. attach(target: Mesh): void;
  36506. /**
  36507. * Detaches the behavior from the mesh
  36508. */
  36509. detach(): void;
  36510. }
  36511. }
  36512. declare module BABYLON {
  36513. /**
  36514. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36515. */
  36516. export class FadeInOutBehavior implements Behavior<Mesh> {
  36517. /**
  36518. * Time in milliseconds to delay before fading in (Default: 0)
  36519. */
  36520. delay: number;
  36521. /**
  36522. * Time in milliseconds for the mesh to fade in (Default: 300)
  36523. */
  36524. fadeInTime: number;
  36525. private _millisecondsPerFrame;
  36526. private _hovered;
  36527. private _hoverValue;
  36528. private _ownerNode;
  36529. /**
  36530. * Instatiates the FadeInOutBehavior
  36531. */
  36532. constructor();
  36533. /**
  36534. * The name of the behavior
  36535. */
  36536. readonly name: string;
  36537. /**
  36538. * Initializes the behavior
  36539. */
  36540. init(): void;
  36541. /**
  36542. * Attaches the fade behavior on the passed in mesh
  36543. * @param ownerNode The mesh that will be faded in/out once attached
  36544. */
  36545. attach(ownerNode: Mesh): void;
  36546. /**
  36547. * Detaches the behavior from the mesh
  36548. */
  36549. detach(): void;
  36550. /**
  36551. * Triggers the mesh to begin fading in or out
  36552. * @param value if the object should fade in or out (true to fade in)
  36553. */
  36554. fadeIn(value: boolean): void;
  36555. private _update;
  36556. private _setAllVisibility;
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. /**
  36561. * Class containing a set of static utilities functions for managing Pivots
  36562. * @hidden
  36563. */
  36564. export class PivotTools {
  36565. private static _PivotCached;
  36566. private static _OldPivotPoint;
  36567. private static _PivotTranslation;
  36568. private static _PivotTmpVector;
  36569. /** @hidden */
  36570. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36571. /** @hidden */
  36572. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36573. }
  36574. }
  36575. declare module BABYLON {
  36576. /**
  36577. * Class containing static functions to help procedurally build meshes
  36578. */
  36579. export class PlaneBuilder {
  36580. /**
  36581. * Creates a plane mesh
  36582. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36583. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36584. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36586. * * 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
  36587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36588. * @param name defines the name of the mesh
  36589. * @param options defines the options used to create the mesh
  36590. * @param scene defines the hosting scene
  36591. * @returns the plane mesh
  36592. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36593. */
  36594. static CreatePlane(name: string, options: {
  36595. size?: number;
  36596. width?: number;
  36597. height?: number;
  36598. sideOrientation?: number;
  36599. frontUVs?: Vector4;
  36600. backUVs?: Vector4;
  36601. updatable?: boolean;
  36602. sourcePlane?: Plane;
  36603. }, scene?: Nullable<Scene>): Mesh;
  36604. }
  36605. }
  36606. declare module BABYLON {
  36607. /**
  36608. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36609. */
  36610. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36611. private static _AnyMouseID;
  36612. /**
  36613. * Abstract mesh the behavior is set on
  36614. */
  36615. attachedNode: AbstractMesh;
  36616. private _dragPlane;
  36617. private _scene;
  36618. private _pointerObserver;
  36619. private _beforeRenderObserver;
  36620. private static _planeScene;
  36621. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36622. /**
  36623. * 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)
  36624. */
  36625. maxDragAngle: number;
  36626. /**
  36627. * @hidden
  36628. */
  36629. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36630. /**
  36631. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36632. */
  36633. currentDraggingPointerID: number;
  36634. /**
  36635. * The last position where the pointer hit the drag plane in world space
  36636. */
  36637. lastDragPosition: Vector3;
  36638. /**
  36639. * If the behavior is currently in a dragging state
  36640. */
  36641. dragging: boolean;
  36642. /**
  36643. * 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)
  36644. */
  36645. dragDeltaRatio: number;
  36646. /**
  36647. * If the drag plane orientation should be updated during the dragging (Default: true)
  36648. */
  36649. updateDragPlane: boolean;
  36650. private _debugMode;
  36651. private _moving;
  36652. /**
  36653. * Fires each time the attached mesh is dragged with the pointer
  36654. * * delta between last drag position and current drag position in world space
  36655. * * dragDistance along the drag axis
  36656. * * dragPlaneNormal normal of the current drag plane used during the drag
  36657. * * dragPlanePoint in world space where the drag intersects the drag plane
  36658. */
  36659. onDragObservable: Observable<{
  36660. delta: Vector3;
  36661. dragPlanePoint: Vector3;
  36662. dragPlaneNormal: Vector3;
  36663. dragDistance: number;
  36664. pointerId: number;
  36665. }>;
  36666. /**
  36667. * Fires each time a drag begins (eg. mouse down on mesh)
  36668. */
  36669. onDragStartObservable: Observable<{
  36670. dragPlanePoint: Vector3;
  36671. pointerId: number;
  36672. }>;
  36673. /**
  36674. * Fires each time a drag ends (eg. mouse release after drag)
  36675. */
  36676. onDragEndObservable: Observable<{
  36677. dragPlanePoint: Vector3;
  36678. pointerId: number;
  36679. }>;
  36680. /**
  36681. * If the attached mesh should be moved when dragged
  36682. */
  36683. moveAttached: boolean;
  36684. /**
  36685. * If the drag behavior will react to drag events (Default: true)
  36686. */
  36687. enabled: boolean;
  36688. /**
  36689. * If pointer events should start and release the drag (Default: true)
  36690. */
  36691. startAndReleaseDragOnPointerEvents: boolean;
  36692. /**
  36693. * If camera controls should be detached during the drag
  36694. */
  36695. detachCameraControls: boolean;
  36696. /**
  36697. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36698. */
  36699. useObjectOrienationForDragging: boolean;
  36700. private _options;
  36701. /**
  36702. * Creates a pointer drag behavior that can be attached to a mesh
  36703. * @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)
  36704. */
  36705. constructor(options?: {
  36706. dragAxis?: Vector3;
  36707. dragPlaneNormal?: Vector3;
  36708. });
  36709. /**
  36710. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36711. */
  36712. validateDrag: (targetPosition: Vector3) => boolean;
  36713. /**
  36714. * The name of the behavior
  36715. */
  36716. readonly name: string;
  36717. /**
  36718. * Initializes the behavior
  36719. */
  36720. init(): void;
  36721. private _tmpVector;
  36722. private _alternatePickedPoint;
  36723. private _worldDragAxis;
  36724. private _targetPosition;
  36725. private _attachedElement;
  36726. /**
  36727. * Attaches the drag behavior the passed in mesh
  36728. * @param ownerNode The mesh that will be dragged around once attached
  36729. */
  36730. attach(ownerNode: AbstractMesh): void;
  36731. /**
  36732. * Force relase the drag action by code.
  36733. */
  36734. releaseDrag(): void;
  36735. private _startDragRay;
  36736. private _lastPointerRay;
  36737. /**
  36738. * Simulates the start of a pointer drag event on the behavior
  36739. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36740. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36741. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36742. */
  36743. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36744. private _startDrag;
  36745. private _dragDelta;
  36746. private _moveDrag;
  36747. private _pickWithRayOnDragPlane;
  36748. private _pointA;
  36749. private _pointB;
  36750. private _pointC;
  36751. private _lineA;
  36752. private _lineB;
  36753. private _localAxis;
  36754. private _lookAt;
  36755. private _updateDragPlanePosition;
  36756. /**
  36757. * Detaches the behavior from the mesh
  36758. */
  36759. detach(): void;
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. /**
  36764. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36765. */
  36766. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36767. private _dragBehaviorA;
  36768. private _dragBehaviorB;
  36769. private _startDistance;
  36770. private _initialScale;
  36771. private _targetScale;
  36772. private _ownerNode;
  36773. private _sceneRenderObserver;
  36774. /**
  36775. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36776. */
  36777. constructor();
  36778. /**
  36779. * The name of the behavior
  36780. */
  36781. readonly name: string;
  36782. /**
  36783. * Initializes the behavior
  36784. */
  36785. init(): void;
  36786. private _getCurrentDistance;
  36787. /**
  36788. * Attaches the scale behavior the passed in mesh
  36789. * @param ownerNode The mesh that will be scaled around once attached
  36790. */
  36791. attach(ownerNode: Mesh): void;
  36792. /**
  36793. * Detaches the behavior from the mesh
  36794. */
  36795. detach(): void;
  36796. }
  36797. }
  36798. declare module BABYLON {
  36799. /**
  36800. * 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
  36801. */
  36802. export class SixDofDragBehavior implements Behavior<Mesh> {
  36803. private static _virtualScene;
  36804. private _ownerNode;
  36805. private _sceneRenderObserver;
  36806. private _scene;
  36807. private _targetPosition;
  36808. private _virtualOriginMesh;
  36809. private _virtualDragMesh;
  36810. private _pointerObserver;
  36811. private _moving;
  36812. private _startingOrientation;
  36813. /**
  36814. * 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)
  36815. */
  36816. private zDragFactor;
  36817. /**
  36818. * If the object should rotate to face the drag origin
  36819. */
  36820. rotateDraggedObject: boolean;
  36821. /**
  36822. * If the behavior is currently in a dragging state
  36823. */
  36824. dragging: boolean;
  36825. /**
  36826. * 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)
  36827. */
  36828. dragDeltaRatio: number;
  36829. /**
  36830. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36831. */
  36832. currentDraggingPointerID: number;
  36833. /**
  36834. * If camera controls should be detached during the drag
  36835. */
  36836. detachCameraControls: boolean;
  36837. /**
  36838. * Fires each time a drag starts
  36839. */
  36840. onDragStartObservable: Observable<{}>;
  36841. /**
  36842. * Fires each time a drag ends (eg. mouse release after drag)
  36843. */
  36844. onDragEndObservable: Observable<{}>;
  36845. /**
  36846. * 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
  36847. */
  36848. constructor();
  36849. /**
  36850. * The name of the behavior
  36851. */
  36852. readonly name: string;
  36853. /**
  36854. * Initializes the behavior
  36855. */
  36856. init(): void;
  36857. /**
  36858. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36859. */
  36860. private readonly _pointerCamera;
  36861. /**
  36862. * Attaches the scale behavior the passed in mesh
  36863. * @param ownerNode The mesh that will be scaled around once attached
  36864. */
  36865. attach(ownerNode: Mesh): void;
  36866. /**
  36867. * Detaches the behavior from the mesh
  36868. */
  36869. detach(): void;
  36870. }
  36871. }
  36872. declare module BABYLON {
  36873. /**
  36874. * Class used to apply inverse kinematics to bones
  36875. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36876. */
  36877. export class BoneIKController {
  36878. private static _tmpVecs;
  36879. private static _tmpQuat;
  36880. private static _tmpMats;
  36881. /**
  36882. * Gets or sets the target mesh
  36883. */
  36884. targetMesh: AbstractMesh;
  36885. /** Gets or sets the mesh used as pole */
  36886. poleTargetMesh: AbstractMesh;
  36887. /**
  36888. * Gets or sets the bone used as pole
  36889. */
  36890. poleTargetBone: Nullable<Bone>;
  36891. /**
  36892. * Gets or sets the target position
  36893. */
  36894. targetPosition: Vector3;
  36895. /**
  36896. * Gets or sets the pole target position
  36897. */
  36898. poleTargetPosition: Vector3;
  36899. /**
  36900. * Gets or sets the pole target local offset
  36901. */
  36902. poleTargetLocalOffset: Vector3;
  36903. /**
  36904. * Gets or sets the pole angle
  36905. */
  36906. poleAngle: number;
  36907. /**
  36908. * Gets or sets the mesh associated with the controller
  36909. */
  36910. mesh: AbstractMesh;
  36911. /**
  36912. * 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)
  36913. */
  36914. slerpAmount: number;
  36915. private _bone1Quat;
  36916. private _bone1Mat;
  36917. private _bone2Ang;
  36918. private _bone1;
  36919. private _bone2;
  36920. private _bone1Length;
  36921. private _bone2Length;
  36922. private _maxAngle;
  36923. private _maxReach;
  36924. private _rightHandedSystem;
  36925. private _bendAxis;
  36926. private _slerping;
  36927. private _adjustRoll;
  36928. /**
  36929. * Gets or sets maximum allowed angle
  36930. */
  36931. maxAngle: number;
  36932. /**
  36933. * Creates a new BoneIKController
  36934. * @param mesh defines the mesh to control
  36935. * @param bone defines the bone to control
  36936. * @param options defines options to set up the controller
  36937. */
  36938. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36939. targetMesh?: AbstractMesh;
  36940. poleTargetMesh?: AbstractMesh;
  36941. poleTargetBone?: Bone;
  36942. poleTargetLocalOffset?: Vector3;
  36943. poleAngle?: number;
  36944. bendAxis?: Vector3;
  36945. maxAngle?: number;
  36946. slerpAmount?: number;
  36947. });
  36948. private _setMaxAngle;
  36949. /**
  36950. * Force the controller to update the bones
  36951. */
  36952. update(): void;
  36953. }
  36954. }
  36955. declare module BABYLON {
  36956. /**
  36957. * Class used to make a bone look toward a point in space
  36958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36959. */
  36960. export class BoneLookController {
  36961. private static _tmpVecs;
  36962. private static _tmpQuat;
  36963. private static _tmpMats;
  36964. /**
  36965. * The target Vector3 that the bone will look at
  36966. */
  36967. target: Vector3;
  36968. /**
  36969. * The mesh that the bone is attached to
  36970. */
  36971. mesh: AbstractMesh;
  36972. /**
  36973. * The bone that will be looking to the target
  36974. */
  36975. bone: Bone;
  36976. /**
  36977. * The up axis of the coordinate system that is used when the bone is rotated
  36978. */
  36979. upAxis: Vector3;
  36980. /**
  36981. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36982. */
  36983. upAxisSpace: Space;
  36984. /**
  36985. * Used to make an adjustment to the yaw of the bone
  36986. */
  36987. adjustYaw: number;
  36988. /**
  36989. * Used to make an adjustment to the pitch of the bone
  36990. */
  36991. adjustPitch: number;
  36992. /**
  36993. * Used to make an adjustment to the roll of the bone
  36994. */
  36995. adjustRoll: number;
  36996. /**
  36997. * 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)
  36998. */
  36999. slerpAmount: number;
  37000. private _minYaw;
  37001. private _maxYaw;
  37002. private _minPitch;
  37003. private _maxPitch;
  37004. private _minYawSin;
  37005. private _minYawCos;
  37006. private _maxYawSin;
  37007. private _maxYawCos;
  37008. private _midYawConstraint;
  37009. private _minPitchTan;
  37010. private _maxPitchTan;
  37011. private _boneQuat;
  37012. private _slerping;
  37013. private _transformYawPitch;
  37014. private _transformYawPitchInv;
  37015. private _firstFrameSkipped;
  37016. private _yawRange;
  37017. private _fowardAxis;
  37018. /**
  37019. * Gets or sets the minimum yaw angle that the bone can look to
  37020. */
  37021. minYaw: number;
  37022. /**
  37023. * Gets or sets the maximum yaw angle that the bone can look to
  37024. */
  37025. maxYaw: number;
  37026. /**
  37027. * Gets or sets the minimum pitch angle that the bone can look to
  37028. */
  37029. minPitch: number;
  37030. /**
  37031. * Gets or sets the maximum pitch angle that the bone can look to
  37032. */
  37033. maxPitch: number;
  37034. /**
  37035. * Create a BoneLookController
  37036. * @param mesh the mesh that the bone belongs to
  37037. * @param bone the bone that will be looking to the target
  37038. * @param target the target Vector3 to look at
  37039. * @param options optional settings:
  37040. * * maxYaw: the maximum angle the bone will yaw to
  37041. * * minYaw: the minimum angle the bone will yaw to
  37042. * * maxPitch: the maximum angle the bone will pitch to
  37043. * * minPitch: the minimum angle the bone will yaw to
  37044. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37045. * * upAxis: the up axis of the coordinate system
  37046. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37047. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37048. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37049. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37050. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37051. * * adjustRoll: used to make an adjustment to the roll of the bone
  37052. **/
  37053. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37054. maxYaw?: number;
  37055. minYaw?: number;
  37056. maxPitch?: number;
  37057. minPitch?: number;
  37058. slerpAmount?: number;
  37059. upAxis?: Vector3;
  37060. upAxisSpace?: Space;
  37061. yawAxis?: Vector3;
  37062. pitchAxis?: Vector3;
  37063. adjustYaw?: number;
  37064. adjustPitch?: number;
  37065. adjustRoll?: number;
  37066. });
  37067. /**
  37068. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37069. */
  37070. update(): void;
  37071. private _getAngleDiff;
  37072. private _getAngleBetween;
  37073. private _isAngleBetween;
  37074. }
  37075. }
  37076. declare module BABYLON {
  37077. /**
  37078. * Manage the gamepad inputs to control an arc rotate camera.
  37079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37080. */
  37081. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37082. /**
  37083. * Defines the camera the input is attached to.
  37084. */
  37085. camera: ArcRotateCamera;
  37086. /**
  37087. * Defines the gamepad the input is gathering event from.
  37088. */
  37089. gamepad: Nullable<Gamepad>;
  37090. /**
  37091. * Defines the gamepad rotation sensiblity.
  37092. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37093. */
  37094. gamepadRotationSensibility: number;
  37095. /**
  37096. * Defines the gamepad move sensiblity.
  37097. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37098. */
  37099. gamepadMoveSensibility: number;
  37100. private _onGamepadConnectedObserver;
  37101. private _onGamepadDisconnectedObserver;
  37102. /**
  37103. * Attach the input controls to a specific dom element to get the input from.
  37104. * @param element Defines the element the controls should be listened from
  37105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37106. */
  37107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37108. /**
  37109. * Detach the current controls from the specified dom element.
  37110. * @param element Defines the element to stop listening the inputs from
  37111. */
  37112. detachControl(element: Nullable<HTMLElement>): void;
  37113. /**
  37114. * Update the current camera state depending on the inputs that have been used this frame.
  37115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37116. */
  37117. checkInputs(): void;
  37118. /**
  37119. * Gets the class name of the current intput.
  37120. * @returns the class name
  37121. */
  37122. getClassName(): string;
  37123. /**
  37124. * Get the friendly name associated with the input class.
  37125. * @returns the input friendly name
  37126. */
  37127. getSimpleName(): string;
  37128. }
  37129. }
  37130. declare module BABYLON {
  37131. interface ArcRotateCameraInputsManager {
  37132. /**
  37133. * Add orientation input support to the input manager.
  37134. * @returns the current input manager
  37135. */
  37136. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37137. }
  37138. /**
  37139. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37141. */
  37142. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37143. /**
  37144. * Defines the camera the input is attached to.
  37145. */
  37146. camera: ArcRotateCamera;
  37147. /**
  37148. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37149. */
  37150. alphaCorrection: number;
  37151. /**
  37152. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37153. */
  37154. gammaCorrection: number;
  37155. private _alpha;
  37156. private _gamma;
  37157. private _dirty;
  37158. private _deviceOrientationHandler;
  37159. /**
  37160. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37161. */
  37162. constructor();
  37163. /**
  37164. * Attach the input controls to a specific dom element to get the input from.
  37165. * @param element Defines the element the controls should be listened from
  37166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37167. */
  37168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37169. /** @hidden */
  37170. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37171. /**
  37172. * Update the current camera state depending on the inputs that have been used this frame.
  37173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37174. */
  37175. checkInputs(): void;
  37176. /**
  37177. * Detach the current controls from the specified dom element.
  37178. * @param element Defines the element to stop listening the inputs from
  37179. */
  37180. detachControl(element: Nullable<HTMLElement>): void;
  37181. /**
  37182. * Gets the class name of the current intput.
  37183. * @returns the class name
  37184. */
  37185. getClassName(): string;
  37186. /**
  37187. * Get the friendly name associated with the input class.
  37188. * @returns the input friendly name
  37189. */
  37190. getSimpleName(): string;
  37191. }
  37192. }
  37193. declare module BABYLON {
  37194. /**
  37195. * Listen to mouse events to control the camera.
  37196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37197. */
  37198. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37199. /**
  37200. * Defines the camera the input is attached to.
  37201. */
  37202. camera: FlyCamera;
  37203. /**
  37204. * Defines if touch is enabled. (Default is true.)
  37205. */
  37206. touchEnabled: boolean;
  37207. /**
  37208. * Defines the buttons associated with the input to handle camera rotation.
  37209. */
  37210. buttons: number[];
  37211. /**
  37212. * Assign buttons for Yaw control.
  37213. */
  37214. buttonsYaw: number[];
  37215. /**
  37216. * Assign buttons for Pitch control.
  37217. */
  37218. buttonsPitch: number[];
  37219. /**
  37220. * Assign buttons for Roll control.
  37221. */
  37222. buttonsRoll: number[];
  37223. /**
  37224. * Detect if any button is being pressed while mouse is moved.
  37225. * -1 = Mouse locked.
  37226. * 0 = Left button.
  37227. * 1 = Middle Button.
  37228. * 2 = Right Button.
  37229. */
  37230. activeButton: number;
  37231. /**
  37232. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37233. * Higher values reduce its sensitivity.
  37234. */
  37235. angularSensibility: number;
  37236. private _mousemoveCallback;
  37237. private _observer;
  37238. private _rollObserver;
  37239. private previousPosition;
  37240. private noPreventDefault;
  37241. private element;
  37242. /**
  37243. * Listen to mouse events to control the camera.
  37244. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37246. */
  37247. constructor(touchEnabled?: boolean);
  37248. /**
  37249. * Attach the mouse control to the HTML DOM element.
  37250. * @param element Defines the element that listens to the input events.
  37251. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37252. */
  37253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37254. /**
  37255. * Detach the current controls from the specified dom element.
  37256. * @param element Defines the element to stop listening the inputs from
  37257. */
  37258. detachControl(element: Nullable<HTMLElement>): void;
  37259. /**
  37260. * Gets the class name of the current input.
  37261. * @returns the class name.
  37262. */
  37263. getClassName(): string;
  37264. /**
  37265. * Get the friendly name associated with the input class.
  37266. * @returns the input's friendly name.
  37267. */
  37268. getSimpleName(): string;
  37269. private _pointerInput;
  37270. private _onMouseMove;
  37271. /**
  37272. * Rotate camera by mouse offset.
  37273. */
  37274. private rotateCamera;
  37275. }
  37276. }
  37277. declare module BABYLON {
  37278. /**
  37279. * Default Inputs manager for the FlyCamera.
  37280. * It groups all the default supported inputs for ease of use.
  37281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37282. */
  37283. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37284. /**
  37285. * Instantiates a new FlyCameraInputsManager.
  37286. * @param camera Defines the camera the inputs belong to.
  37287. */
  37288. constructor(camera: FlyCamera);
  37289. /**
  37290. * Add keyboard input support to the input manager.
  37291. * @returns the new FlyCameraKeyboardMoveInput().
  37292. */
  37293. addKeyboard(): FlyCameraInputsManager;
  37294. /**
  37295. * Add mouse input support to the input manager.
  37296. * @param touchEnabled Enable touch screen support.
  37297. * @returns the new FlyCameraMouseInput().
  37298. */
  37299. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37300. }
  37301. }
  37302. declare module BABYLON {
  37303. /**
  37304. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37305. * such as in a 3D Space Shooter or a Flight Simulator.
  37306. */
  37307. export class FlyCamera extends TargetCamera {
  37308. /**
  37309. * Define the collision ellipsoid of the camera.
  37310. * This is helpful for simulating a camera body, like a player's body.
  37311. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37312. */
  37313. ellipsoid: Vector3;
  37314. /**
  37315. * Define an offset for the position of the ellipsoid around the camera.
  37316. * This can be helpful if the camera is attached away from the player's body center,
  37317. * such as at its head.
  37318. */
  37319. ellipsoidOffset: Vector3;
  37320. /**
  37321. * Enable or disable collisions of the camera with the rest of the scene objects.
  37322. */
  37323. checkCollisions: boolean;
  37324. /**
  37325. * Enable or disable gravity on the camera.
  37326. */
  37327. applyGravity: boolean;
  37328. /**
  37329. * Define the current direction the camera is moving to.
  37330. */
  37331. cameraDirection: Vector3;
  37332. /**
  37333. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37334. * This overrides and empties cameraRotation.
  37335. */
  37336. rotationQuaternion: Quaternion;
  37337. /**
  37338. * Track Roll to maintain the wanted Rolling when looking around.
  37339. */
  37340. _trackRoll: number;
  37341. /**
  37342. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37343. */
  37344. rollCorrect: number;
  37345. /**
  37346. * Mimic a banked turn, Rolling the camera when Yawing.
  37347. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37348. */
  37349. bankedTurn: boolean;
  37350. /**
  37351. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37352. */
  37353. bankedTurnLimit: number;
  37354. /**
  37355. * Value of 0 disables the banked Roll.
  37356. * Value of 1 is equal to the Yaw angle in radians.
  37357. */
  37358. bankedTurnMultiplier: number;
  37359. /**
  37360. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37361. */
  37362. inputs: FlyCameraInputsManager;
  37363. /**
  37364. * Gets the input sensibility for mouse input.
  37365. * Higher values reduce sensitivity.
  37366. */
  37367. /**
  37368. * Sets the input sensibility for a mouse input.
  37369. * Higher values reduce sensitivity.
  37370. */
  37371. angularSensibility: number;
  37372. /**
  37373. * Get the keys for camera movement forward.
  37374. */
  37375. /**
  37376. * Set the keys for camera movement forward.
  37377. */
  37378. keysForward: number[];
  37379. /**
  37380. * Get the keys for camera movement backward.
  37381. */
  37382. keysBackward: number[];
  37383. /**
  37384. * Get the keys for camera movement up.
  37385. */
  37386. /**
  37387. * Set the keys for camera movement up.
  37388. */
  37389. keysUp: number[];
  37390. /**
  37391. * Get the keys for camera movement down.
  37392. */
  37393. /**
  37394. * Set the keys for camera movement down.
  37395. */
  37396. keysDown: number[];
  37397. /**
  37398. * Get the keys for camera movement left.
  37399. */
  37400. /**
  37401. * Set the keys for camera movement left.
  37402. */
  37403. keysLeft: number[];
  37404. /**
  37405. * Set the keys for camera movement right.
  37406. */
  37407. /**
  37408. * Set the keys for camera movement right.
  37409. */
  37410. keysRight: number[];
  37411. /**
  37412. * Event raised when the camera collides with a mesh in the scene.
  37413. */
  37414. onCollide: (collidedMesh: AbstractMesh) => void;
  37415. private _collider;
  37416. private _needMoveForGravity;
  37417. private _oldPosition;
  37418. private _diffPosition;
  37419. private _newPosition;
  37420. /** @hidden */
  37421. _localDirection: Vector3;
  37422. /** @hidden */
  37423. _transformedDirection: Vector3;
  37424. /**
  37425. * Instantiates a FlyCamera.
  37426. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37427. * such as in a 3D Space Shooter or a Flight Simulator.
  37428. * @param name Define the name of the camera in the scene.
  37429. * @param position Define the starting position of the camera in the scene.
  37430. * @param scene Define the scene the camera belongs to.
  37431. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37432. */
  37433. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37434. /**
  37435. * Attach a control to the HTML DOM element.
  37436. * @param element Defines the element that listens to the input events.
  37437. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37438. */
  37439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37440. /**
  37441. * Detach a control from the HTML DOM element.
  37442. * The camera will stop reacting to that input.
  37443. * @param element Defines the element that listens to the input events.
  37444. */
  37445. detachControl(element: HTMLElement): void;
  37446. private _collisionMask;
  37447. /**
  37448. * Get the mask that the camera ignores in collision events.
  37449. */
  37450. /**
  37451. * Set the mask that the camera ignores in collision events.
  37452. */
  37453. collisionMask: number;
  37454. /** @hidden */
  37455. _collideWithWorld(displacement: Vector3): void;
  37456. /** @hidden */
  37457. private _onCollisionPositionChange;
  37458. /** @hidden */
  37459. _checkInputs(): void;
  37460. /** @hidden */
  37461. _decideIfNeedsToMove(): boolean;
  37462. /** @hidden */
  37463. _updatePosition(): void;
  37464. /**
  37465. * Restore the Roll to its target value at the rate specified.
  37466. * @param rate - Higher means slower restoring.
  37467. * @hidden
  37468. */
  37469. restoreRoll(rate: number): void;
  37470. /**
  37471. * Destroy the camera and release the current resources held by it.
  37472. */
  37473. dispose(): void;
  37474. /**
  37475. * Get the current object class name.
  37476. * @returns the class name.
  37477. */
  37478. getClassName(): string;
  37479. }
  37480. }
  37481. declare module BABYLON {
  37482. /**
  37483. * Listen to keyboard events to control the camera.
  37484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37485. */
  37486. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37487. /**
  37488. * Defines the camera the input is attached to.
  37489. */
  37490. camera: FlyCamera;
  37491. /**
  37492. * The list of keyboard keys used to control the forward move of the camera.
  37493. */
  37494. keysForward: number[];
  37495. /**
  37496. * The list of keyboard keys used to control the backward move of the camera.
  37497. */
  37498. keysBackward: number[];
  37499. /**
  37500. * The list of keyboard keys used to control the forward move of the camera.
  37501. */
  37502. keysUp: number[];
  37503. /**
  37504. * The list of keyboard keys used to control the backward move of the camera.
  37505. */
  37506. keysDown: number[];
  37507. /**
  37508. * The list of keyboard keys used to control the right strafe move of the camera.
  37509. */
  37510. keysRight: number[];
  37511. /**
  37512. * The list of keyboard keys used to control the left strafe move of the camera.
  37513. */
  37514. keysLeft: number[];
  37515. private _keys;
  37516. private _onCanvasBlurObserver;
  37517. private _onKeyboardObserver;
  37518. private _engine;
  37519. private _scene;
  37520. /**
  37521. * Attach the input controls to a specific dom element to get the input from.
  37522. * @param element Defines the element the controls should be listened from
  37523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37524. */
  37525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37526. /**
  37527. * Detach the current controls from the specified dom element.
  37528. * @param element Defines the element to stop listening the inputs from
  37529. */
  37530. detachControl(element: Nullable<HTMLElement>): void;
  37531. /**
  37532. * Gets the class name of the current intput.
  37533. * @returns the class name
  37534. */
  37535. getClassName(): string;
  37536. /** @hidden */
  37537. _onLostFocus(e: FocusEvent): void;
  37538. /**
  37539. * Get the friendly name associated with the input class.
  37540. * @returns the input friendly name
  37541. */
  37542. getSimpleName(): string;
  37543. /**
  37544. * Update the current camera state depending on the inputs that have been used this frame.
  37545. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37546. */
  37547. checkInputs(): void;
  37548. }
  37549. }
  37550. declare module BABYLON {
  37551. /**
  37552. * Manage the mouse wheel inputs to control a follow camera.
  37553. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37554. */
  37555. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37556. /**
  37557. * Defines the camera the input is attached to.
  37558. */
  37559. camera: FollowCamera;
  37560. /**
  37561. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37562. */
  37563. axisControlRadius: boolean;
  37564. /**
  37565. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37566. */
  37567. axisControlHeight: boolean;
  37568. /**
  37569. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37570. */
  37571. axisControlRotation: boolean;
  37572. /**
  37573. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37574. * relation to mouseWheel events.
  37575. */
  37576. wheelPrecision: number;
  37577. /**
  37578. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37579. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37580. */
  37581. wheelDeltaPercentage: number;
  37582. private _wheel;
  37583. private _observer;
  37584. /**
  37585. * Attach the input controls to a specific dom element to get the input from.
  37586. * @param element Defines the element the controls should be listened from
  37587. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37588. */
  37589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37590. /**
  37591. * Detach the current controls from the specified dom element.
  37592. * @param element Defines the element to stop listening the inputs from
  37593. */
  37594. detachControl(element: Nullable<HTMLElement>): void;
  37595. /**
  37596. * Gets the class name of the current intput.
  37597. * @returns the class name
  37598. */
  37599. getClassName(): string;
  37600. /**
  37601. * Get the friendly name associated with the input class.
  37602. * @returns the input friendly name
  37603. */
  37604. getSimpleName(): string;
  37605. }
  37606. }
  37607. declare module BABYLON {
  37608. /**
  37609. * Manage the pointers inputs to control an follow camera.
  37610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37611. */
  37612. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37613. /**
  37614. * Defines the camera the input is attached to.
  37615. */
  37616. camera: FollowCamera;
  37617. /**
  37618. * Gets the class name of the current input.
  37619. * @returns the class name
  37620. */
  37621. getClassName(): string;
  37622. /**
  37623. * Defines the pointer angular sensibility along the X axis or how fast is
  37624. * the camera rotating.
  37625. * A negative number will reverse the axis direction.
  37626. */
  37627. angularSensibilityX: number;
  37628. /**
  37629. * Defines the pointer angular sensibility along the Y axis or how fast is
  37630. * the camera rotating.
  37631. * A negative number will reverse the axis direction.
  37632. */
  37633. angularSensibilityY: number;
  37634. /**
  37635. * Defines the pointer pinch precision or how fast is the camera zooming.
  37636. * A negative number will reverse the axis direction.
  37637. */
  37638. pinchPrecision: number;
  37639. /**
  37640. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37641. * from 0.
  37642. * It defines the percentage of current camera.radius to use as delta when
  37643. * pinch zoom is used.
  37644. */
  37645. pinchDeltaPercentage: number;
  37646. /**
  37647. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37648. */
  37649. axisXControlRadius: boolean;
  37650. /**
  37651. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37652. */
  37653. axisXControlHeight: boolean;
  37654. /**
  37655. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37656. */
  37657. axisXControlRotation: boolean;
  37658. /**
  37659. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37660. */
  37661. axisYControlRadius: boolean;
  37662. /**
  37663. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37664. */
  37665. axisYControlHeight: boolean;
  37666. /**
  37667. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37668. */
  37669. axisYControlRotation: boolean;
  37670. /**
  37671. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37672. */
  37673. axisPinchControlRadius: boolean;
  37674. /**
  37675. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37676. */
  37677. axisPinchControlHeight: boolean;
  37678. /**
  37679. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37680. */
  37681. axisPinchControlRotation: boolean;
  37682. /**
  37683. * Log error messages if basic misconfiguration has occurred.
  37684. */
  37685. warningEnable: boolean;
  37686. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37687. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37688. private _warningCounter;
  37689. private _warning;
  37690. }
  37691. }
  37692. declare module BABYLON {
  37693. /**
  37694. * Default Inputs manager for the FollowCamera.
  37695. * It groups all the default supported inputs for ease of use.
  37696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37697. */
  37698. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37699. /**
  37700. * Instantiates a new FollowCameraInputsManager.
  37701. * @param camera Defines the camera the inputs belong to
  37702. */
  37703. constructor(camera: FollowCamera);
  37704. /**
  37705. * Add keyboard input support to the input manager.
  37706. * @returns the current input manager
  37707. */
  37708. addKeyboard(): FollowCameraInputsManager;
  37709. /**
  37710. * Add mouse wheel input support to the input manager.
  37711. * @returns the current input manager
  37712. */
  37713. addMouseWheel(): FollowCameraInputsManager;
  37714. /**
  37715. * Add pointers input support to the input manager.
  37716. * @returns the current input manager
  37717. */
  37718. addPointers(): FollowCameraInputsManager;
  37719. /**
  37720. * Add orientation input support to the input manager.
  37721. * @returns the current input manager
  37722. */
  37723. addVRDeviceOrientation(): FollowCameraInputsManager;
  37724. }
  37725. }
  37726. declare module BABYLON {
  37727. /**
  37728. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37729. * an arc rotate version arcFollowCamera are available.
  37730. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37731. */
  37732. export class FollowCamera extends TargetCamera {
  37733. /**
  37734. * Distance the follow camera should follow an object at
  37735. */
  37736. radius: number;
  37737. /**
  37738. * Minimum allowed distance of the camera to the axis of rotation
  37739. * (The camera can not get closer).
  37740. * This can help limiting how the Camera is able to move in the scene.
  37741. */
  37742. lowerRadiusLimit: Nullable<number>;
  37743. /**
  37744. * Maximum allowed distance of the camera to the axis of rotation
  37745. * (The camera can not get further).
  37746. * This can help limiting how the Camera is able to move in the scene.
  37747. */
  37748. upperRadiusLimit: Nullable<number>;
  37749. /**
  37750. * Define a rotation offset between the camera and the object it follows
  37751. */
  37752. rotationOffset: number;
  37753. /**
  37754. * Minimum allowed angle to camera position relative to target object.
  37755. * This can help limiting how the Camera is able to move in the scene.
  37756. */
  37757. lowerRotationOffsetLimit: Nullable<number>;
  37758. /**
  37759. * Maximum allowed angle to camera position relative to target object.
  37760. * This can help limiting how the Camera is able to move in the scene.
  37761. */
  37762. upperRotationOffsetLimit: Nullable<number>;
  37763. /**
  37764. * Define a height offset between the camera and the object it follows.
  37765. * It can help following an object from the top (like a car chaing a plane)
  37766. */
  37767. heightOffset: number;
  37768. /**
  37769. * Minimum allowed height of camera position relative to target object.
  37770. * This can help limiting how the Camera is able to move in the scene.
  37771. */
  37772. lowerHeightOffsetLimit: Nullable<number>;
  37773. /**
  37774. * Maximum allowed height of camera position relative to target object.
  37775. * This can help limiting how the Camera is able to move in the scene.
  37776. */
  37777. upperHeightOffsetLimit: Nullable<number>;
  37778. /**
  37779. * Define how fast the camera can accelerate to follow it s target.
  37780. */
  37781. cameraAcceleration: number;
  37782. /**
  37783. * Define the speed limit of the camera following an object.
  37784. */
  37785. maxCameraSpeed: number;
  37786. /**
  37787. * Define the target of the camera.
  37788. */
  37789. lockedTarget: Nullable<AbstractMesh>;
  37790. /**
  37791. * Defines the input associated with the camera.
  37792. */
  37793. inputs: FollowCameraInputsManager;
  37794. /**
  37795. * Instantiates the follow camera.
  37796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37797. * @param name Define the name of the camera in the scene
  37798. * @param position Define the position of the camera
  37799. * @param scene Define the scene the camera belong to
  37800. * @param lockedTarget Define the target of the camera
  37801. */
  37802. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37803. private _follow;
  37804. /**
  37805. * Attached controls to the current camera.
  37806. * @param element Defines the element the controls should be listened from
  37807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37808. */
  37809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37810. /**
  37811. * Detach the current controls from the camera.
  37812. * The camera will stop reacting to inputs.
  37813. * @param element Defines the element to stop listening the inputs from
  37814. */
  37815. detachControl(element: HTMLElement): void;
  37816. /** @hidden */
  37817. _checkInputs(): void;
  37818. private _checkLimits;
  37819. /**
  37820. * Gets the camera class name.
  37821. * @returns the class name
  37822. */
  37823. getClassName(): string;
  37824. }
  37825. /**
  37826. * Arc Rotate version of the follow camera.
  37827. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37828. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37829. */
  37830. export class ArcFollowCamera extends TargetCamera {
  37831. /** The longitudinal angle of the camera */
  37832. alpha: number;
  37833. /** The latitudinal angle of the camera */
  37834. beta: number;
  37835. /** The radius of the camera from its target */
  37836. radius: number;
  37837. /** Define the camera target (the messh it should follow) */
  37838. target: Nullable<AbstractMesh>;
  37839. private _cartesianCoordinates;
  37840. /**
  37841. * Instantiates a new ArcFollowCamera
  37842. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37843. * @param name Define the name of the camera
  37844. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37845. * @param beta Define the rotation angle of the camera around the elevation axis
  37846. * @param radius Define the radius of the camera from its target point
  37847. * @param target Define the target of the camera
  37848. * @param scene Define the scene the camera belongs to
  37849. */
  37850. constructor(name: string,
  37851. /** The longitudinal angle of the camera */
  37852. alpha: number,
  37853. /** The latitudinal angle of the camera */
  37854. beta: number,
  37855. /** The radius of the camera from its target */
  37856. radius: number,
  37857. /** Define the camera target (the messh it should follow) */
  37858. target: Nullable<AbstractMesh>, scene: Scene);
  37859. private _follow;
  37860. /** @hidden */
  37861. _checkInputs(): void;
  37862. /**
  37863. * Returns the class name of the object.
  37864. * It is mostly used internally for serialization purposes.
  37865. */
  37866. getClassName(): string;
  37867. }
  37868. }
  37869. declare module BABYLON {
  37870. /**
  37871. * Manage the keyboard inputs to control the movement of a follow camera.
  37872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37873. */
  37874. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37875. /**
  37876. * Defines the camera the input is attached to.
  37877. */
  37878. camera: FollowCamera;
  37879. /**
  37880. * Defines the list of key codes associated with the up action (increase heightOffset)
  37881. */
  37882. keysHeightOffsetIncr: number[];
  37883. /**
  37884. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37885. */
  37886. keysHeightOffsetDecr: number[];
  37887. /**
  37888. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37889. */
  37890. keysHeightOffsetModifierAlt: boolean;
  37891. /**
  37892. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37893. */
  37894. keysHeightOffsetModifierCtrl: boolean;
  37895. /**
  37896. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37897. */
  37898. keysHeightOffsetModifierShift: boolean;
  37899. /**
  37900. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37901. */
  37902. keysRotationOffsetIncr: number[];
  37903. /**
  37904. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37905. */
  37906. keysRotationOffsetDecr: number[];
  37907. /**
  37908. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37909. */
  37910. keysRotationOffsetModifierAlt: boolean;
  37911. /**
  37912. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37913. */
  37914. keysRotationOffsetModifierCtrl: boolean;
  37915. /**
  37916. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37917. */
  37918. keysRotationOffsetModifierShift: boolean;
  37919. /**
  37920. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37921. */
  37922. keysRadiusIncr: number[];
  37923. /**
  37924. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37925. */
  37926. keysRadiusDecr: number[];
  37927. /**
  37928. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37929. */
  37930. keysRadiusModifierAlt: boolean;
  37931. /**
  37932. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37933. */
  37934. keysRadiusModifierCtrl: boolean;
  37935. /**
  37936. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37937. */
  37938. keysRadiusModifierShift: boolean;
  37939. /**
  37940. * Defines the rate of change of heightOffset.
  37941. */
  37942. heightSensibility: number;
  37943. /**
  37944. * Defines the rate of change of rotationOffset.
  37945. */
  37946. rotationSensibility: number;
  37947. /**
  37948. * Defines the rate of change of radius.
  37949. */
  37950. radiusSensibility: number;
  37951. private _keys;
  37952. private _ctrlPressed;
  37953. private _altPressed;
  37954. private _shiftPressed;
  37955. private _onCanvasBlurObserver;
  37956. private _onKeyboardObserver;
  37957. private _engine;
  37958. private _scene;
  37959. /**
  37960. * Attach the input controls to a specific dom element to get the input from.
  37961. * @param element Defines the element the controls should be listened from
  37962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37963. */
  37964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37965. /**
  37966. * Detach the current controls from the specified dom element.
  37967. * @param element Defines the element to stop listening the inputs from
  37968. */
  37969. detachControl(element: Nullable<HTMLElement>): void;
  37970. /**
  37971. * Update the current camera state depending on the inputs that have been used this frame.
  37972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37973. */
  37974. checkInputs(): void;
  37975. /**
  37976. * Gets the class name of the current input.
  37977. * @returns the class name
  37978. */
  37979. getClassName(): string;
  37980. /**
  37981. * Get the friendly name associated with the input class.
  37982. * @returns the input friendly name
  37983. */
  37984. getSimpleName(): string;
  37985. /**
  37986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37987. * allow modification of the heightOffset value.
  37988. */
  37989. private _modifierHeightOffset;
  37990. /**
  37991. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37992. * allow modification of the rotationOffset value.
  37993. */
  37994. private _modifierRotationOffset;
  37995. /**
  37996. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37997. * allow modification of the radius value.
  37998. */
  37999. private _modifierRadius;
  38000. }
  38001. }
  38002. declare module BABYLON {
  38003. interface FreeCameraInputsManager {
  38004. /**
  38005. * @hidden
  38006. */
  38007. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38008. /**
  38009. * Add orientation input support to the input manager.
  38010. * @returns the current input manager
  38011. */
  38012. addDeviceOrientation(): FreeCameraInputsManager;
  38013. }
  38014. /**
  38015. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38016. * Screen rotation is taken into account.
  38017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38018. */
  38019. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38020. private _camera;
  38021. private _screenOrientationAngle;
  38022. private _constantTranform;
  38023. private _screenQuaternion;
  38024. private _alpha;
  38025. private _beta;
  38026. private _gamma;
  38027. /**
  38028. * Can be used to detect if a device orientation sensor is availible on a device
  38029. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38030. * @returns a promise that will resolve on orientation change
  38031. */
  38032. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38033. /**
  38034. * @hidden
  38035. */
  38036. _onDeviceOrientationChangedObservable: Observable<void>;
  38037. /**
  38038. * Instantiates a new input
  38039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38040. */
  38041. constructor();
  38042. /**
  38043. * Define the camera controlled by the input.
  38044. */
  38045. camera: FreeCamera;
  38046. /**
  38047. * Attach the input controls to a specific dom element to get the input from.
  38048. * @param element Defines the element the controls should be listened from
  38049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38050. */
  38051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38052. private _orientationChanged;
  38053. private _deviceOrientation;
  38054. /**
  38055. * Detach the current controls from the specified dom element.
  38056. * @param element Defines the element to stop listening the inputs from
  38057. */
  38058. detachControl(element: Nullable<HTMLElement>): void;
  38059. /**
  38060. * Update the current camera state depending on the inputs that have been used this frame.
  38061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38062. */
  38063. checkInputs(): void;
  38064. /**
  38065. * Gets the class name of the current intput.
  38066. * @returns the class name
  38067. */
  38068. getClassName(): string;
  38069. /**
  38070. * Get the friendly name associated with the input class.
  38071. * @returns the input friendly name
  38072. */
  38073. getSimpleName(): string;
  38074. }
  38075. }
  38076. declare module BABYLON {
  38077. /**
  38078. * Manage the gamepad inputs to control a free camera.
  38079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38080. */
  38081. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38082. /**
  38083. * Define the camera the input is attached to.
  38084. */
  38085. camera: FreeCamera;
  38086. /**
  38087. * Define the Gamepad controlling the input
  38088. */
  38089. gamepad: Nullable<Gamepad>;
  38090. /**
  38091. * Defines the gamepad rotation sensiblity.
  38092. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38093. */
  38094. gamepadAngularSensibility: number;
  38095. /**
  38096. * Defines the gamepad move sensiblity.
  38097. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38098. */
  38099. gamepadMoveSensibility: number;
  38100. private _onGamepadConnectedObserver;
  38101. private _onGamepadDisconnectedObserver;
  38102. private _cameraTransform;
  38103. private _deltaTransform;
  38104. private _vector3;
  38105. private _vector2;
  38106. /**
  38107. * Attach the input controls to a specific dom element to get the input from.
  38108. * @param element Defines the element the controls should be listened from
  38109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38110. */
  38111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38112. /**
  38113. * Detach the current controls from the specified dom element.
  38114. * @param element Defines the element to stop listening the inputs from
  38115. */
  38116. detachControl(element: Nullable<HTMLElement>): void;
  38117. /**
  38118. * Update the current camera state depending on the inputs that have been used this frame.
  38119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38120. */
  38121. checkInputs(): void;
  38122. /**
  38123. * Gets the class name of the current intput.
  38124. * @returns the class name
  38125. */
  38126. getClassName(): string;
  38127. /**
  38128. * Get the friendly name associated with the input class.
  38129. * @returns the input friendly name
  38130. */
  38131. getSimpleName(): string;
  38132. }
  38133. }
  38134. declare module BABYLON {
  38135. /**
  38136. * Defines the potential axis of a Joystick
  38137. */
  38138. export enum JoystickAxis {
  38139. /** X axis */
  38140. X = 0,
  38141. /** Y axis */
  38142. Y = 1,
  38143. /** Z axis */
  38144. Z = 2
  38145. }
  38146. /**
  38147. * Class used to define virtual joystick (used in touch mode)
  38148. */
  38149. export class VirtualJoystick {
  38150. /**
  38151. * Gets or sets a boolean indicating that left and right values must be inverted
  38152. */
  38153. reverseLeftRight: boolean;
  38154. /**
  38155. * Gets or sets a boolean indicating that up and down values must be inverted
  38156. */
  38157. reverseUpDown: boolean;
  38158. /**
  38159. * Gets the offset value for the position (ie. the change of the position value)
  38160. */
  38161. deltaPosition: Vector3;
  38162. /**
  38163. * Gets a boolean indicating if the virtual joystick was pressed
  38164. */
  38165. pressed: boolean;
  38166. /**
  38167. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38168. */
  38169. static Canvas: Nullable<HTMLCanvasElement>;
  38170. private static _globalJoystickIndex;
  38171. private static vjCanvasContext;
  38172. private static vjCanvasWidth;
  38173. private static vjCanvasHeight;
  38174. private static halfWidth;
  38175. private _action;
  38176. private _axisTargetedByLeftAndRight;
  38177. private _axisTargetedByUpAndDown;
  38178. private _joystickSensibility;
  38179. private _inversedSensibility;
  38180. private _joystickPointerID;
  38181. private _joystickColor;
  38182. private _joystickPointerPos;
  38183. private _joystickPreviousPointerPos;
  38184. private _joystickPointerStartPos;
  38185. private _deltaJoystickVector;
  38186. private _leftJoystick;
  38187. private _touches;
  38188. private _onPointerDownHandlerRef;
  38189. private _onPointerMoveHandlerRef;
  38190. private _onPointerUpHandlerRef;
  38191. private _onResize;
  38192. /**
  38193. * Creates a new virtual joystick
  38194. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38195. */
  38196. constructor(leftJoystick?: boolean);
  38197. /**
  38198. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38199. * @param newJoystickSensibility defines the new sensibility
  38200. */
  38201. setJoystickSensibility(newJoystickSensibility: number): void;
  38202. private _onPointerDown;
  38203. private _onPointerMove;
  38204. private _onPointerUp;
  38205. /**
  38206. * Change the color of the virtual joystick
  38207. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38208. */
  38209. setJoystickColor(newColor: string): void;
  38210. /**
  38211. * Defines a callback to call when the joystick is touched
  38212. * @param action defines the callback
  38213. */
  38214. setActionOnTouch(action: () => any): void;
  38215. /**
  38216. * Defines which axis you'd like to control for left & right
  38217. * @param axis defines the axis to use
  38218. */
  38219. setAxisForLeftRight(axis: JoystickAxis): void;
  38220. /**
  38221. * Defines which axis you'd like to control for up & down
  38222. * @param axis defines the axis to use
  38223. */
  38224. setAxisForUpDown(axis: JoystickAxis): void;
  38225. private _drawVirtualJoystick;
  38226. /**
  38227. * Release internal HTML canvas
  38228. */
  38229. releaseCanvas(): void;
  38230. }
  38231. }
  38232. declare module BABYLON {
  38233. interface FreeCameraInputsManager {
  38234. /**
  38235. * Add virtual joystick input support to the input manager.
  38236. * @returns the current input manager
  38237. */
  38238. addVirtualJoystick(): FreeCameraInputsManager;
  38239. }
  38240. /**
  38241. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38243. */
  38244. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38245. /**
  38246. * Defines the camera the input is attached to.
  38247. */
  38248. camera: FreeCamera;
  38249. private _leftjoystick;
  38250. private _rightjoystick;
  38251. /**
  38252. * Gets the left stick of the virtual joystick.
  38253. * @returns The virtual Joystick
  38254. */
  38255. getLeftJoystick(): VirtualJoystick;
  38256. /**
  38257. * Gets the right stick of the virtual joystick.
  38258. * @returns The virtual Joystick
  38259. */
  38260. getRightJoystick(): VirtualJoystick;
  38261. /**
  38262. * Update the current camera state depending on the inputs that have been used this frame.
  38263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38264. */
  38265. checkInputs(): void;
  38266. /**
  38267. * Attach the input controls to a specific dom element to get the input from.
  38268. * @param element Defines the element the controls should be listened from
  38269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38270. */
  38271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38272. /**
  38273. * Detach the current controls from the specified dom element.
  38274. * @param element Defines the element to stop listening the inputs from
  38275. */
  38276. detachControl(element: Nullable<HTMLElement>): void;
  38277. /**
  38278. * Gets the class name of the current intput.
  38279. * @returns the class name
  38280. */
  38281. getClassName(): string;
  38282. /**
  38283. * Get the friendly name associated with the input class.
  38284. * @returns the input friendly name
  38285. */
  38286. getSimpleName(): string;
  38287. }
  38288. }
  38289. declare module BABYLON {
  38290. /**
  38291. * This represents a FPS type of camera controlled by touch.
  38292. * This is like a universal camera minus the Gamepad controls.
  38293. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38294. */
  38295. export class TouchCamera extends FreeCamera {
  38296. /**
  38297. * Defines the touch sensibility for rotation.
  38298. * The higher the faster.
  38299. */
  38300. touchAngularSensibility: number;
  38301. /**
  38302. * Defines the touch sensibility for move.
  38303. * The higher the faster.
  38304. */
  38305. touchMoveSensibility: number;
  38306. /**
  38307. * Instantiates a new touch camera.
  38308. * This represents a FPS type of camera controlled by touch.
  38309. * This is like a universal camera minus the Gamepad controls.
  38310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38311. * @param name Define the name of the camera in the scene
  38312. * @param position Define the start position of the camera in the scene
  38313. * @param scene Define the scene the camera belongs to
  38314. */
  38315. constructor(name: string, position: Vector3, scene: Scene);
  38316. /**
  38317. * Gets the current object class name.
  38318. * @return the class name
  38319. */
  38320. getClassName(): string;
  38321. /** @hidden */
  38322. _setupInputs(): void;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /**
  38327. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38328. * being tilted forward or back and left or right.
  38329. */
  38330. export class DeviceOrientationCamera extends FreeCamera {
  38331. private _initialQuaternion;
  38332. private _quaternionCache;
  38333. private _tmpDragQuaternion;
  38334. private _disablePointerInputWhenUsingDeviceOrientation;
  38335. /**
  38336. * Creates a new device orientation camera
  38337. * @param name The name of the camera
  38338. * @param position The start position camera
  38339. * @param scene The scene the camera belongs to
  38340. */
  38341. constructor(name: string, position: Vector3, scene: Scene);
  38342. /**
  38343. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38344. */
  38345. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38346. private _dragFactor;
  38347. /**
  38348. * Enabled turning on the y axis when the orientation sensor is active
  38349. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38350. */
  38351. enableHorizontalDragging(dragFactor?: number): void;
  38352. /**
  38353. * Gets the current instance class name ("DeviceOrientationCamera").
  38354. * This helps avoiding instanceof at run time.
  38355. * @returns the class name
  38356. */
  38357. getClassName(): string;
  38358. /**
  38359. * @hidden
  38360. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38361. */
  38362. _checkInputs(): void;
  38363. /**
  38364. * Reset the camera to its default orientation on the specified axis only.
  38365. * @param axis The axis to reset
  38366. */
  38367. resetToCurrentRotation(axis?: Axis): void;
  38368. }
  38369. }
  38370. declare module BABYLON {
  38371. /**
  38372. * Defines supported buttons for XBox360 compatible gamepads
  38373. */
  38374. export enum Xbox360Button {
  38375. /** A */
  38376. A = 0,
  38377. /** B */
  38378. B = 1,
  38379. /** X */
  38380. X = 2,
  38381. /** Y */
  38382. Y = 3,
  38383. /** Start */
  38384. Start = 4,
  38385. /** Back */
  38386. Back = 5,
  38387. /** Left button */
  38388. LB = 6,
  38389. /** Right button */
  38390. RB = 7,
  38391. /** Left stick */
  38392. LeftStick = 8,
  38393. /** Right stick */
  38394. RightStick = 9
  38395. }
  38396. /** Defines values for XBox360 DPad */
  38397. export enum Xbox360Dpad {
  38398. /** Up */
  38399. Up = 0,
  38400. /** Down */
  38401. Down = 1,
  38402. /** Left */
  38403. Left = 2,
  38404. /** Right */
  38405. Right = 3
  38406. }
  38407. /**
  38408. * Defines a XBox360 gamepad
  38409. */
  38410. export class Xbox360Pad extends Gamepad {
  38411. private _leftTrigger;
  38412. private _rightTrigger;
  38413. private _onlefttriggerchanged;
  38414. private _onrighttriggerchanged;
  38415. private _onbuttondown;
  38416. private _onbuttonup;
  38417. private _ondpaddown;
  38418. private _ondpadup;
  38419. /** Observable raised when a button is pressed */
  38420. onButtonDownObservable: Observable<Xbox360Button>;
  38421. /** Observable raised when a button is released */
  38422. onButtonUpObservable: Observable<Xbox360Button>;
  38423. /** Observable raised when a pad is pressed */
  38424. onPadDownObservable: Observable<Xbox360Dpad>;
  38425. /** Observable raised when a pad is released */
  38426. onPadUpObservable: Observable<Xbox360Dpad>;
  38427. private _buttonA;
  38428. private _buttonB;
  38429. private _buttonX;
  38430. private _buttonY;
  38431. private _buttonBack;
  38432. private _buttonStart;
  38433. private _buttonLB;
  38434. private _buttonRB;
  38435. private _buttonLeftStick;
  38436. private _buttonRightStick;
  38437. private _dPadUp;
  38438. private _dPadDown;
  38439. private _dPadLeft;
  38440. private _dPadRight;
  38441. private _isXboxOnePad;
  38442. /**
  38443. * Creates a new XBox360 gamepad object
  38444. * @param id defines the id of this gamepad
  38445. * @param index defines its index
  38446. * @param gamepad defines the internal HTML gamepad object
  38447. * @param xboxOne defines if it is a XBox One gamepad
  38448. */
  38449. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38450. /**
  38451. * Defines the callback to call when left trigger is pressed
  38452. * @param callback defines the callback to use
  38453. */
  38454. onlefttriggerchanged(callback: (value: number) => void): void;
  38455. /**
  38456. * Defines the callback to call when right trigger is pressed
  38457. * @param callback defines the callback to use
  38458. */
  38459. onrighttriggerchanged(callback: (value: number) => void): void;
  38460. /**
  38461. * Gets the left trigger value
  38462. */
  38463. /**
  38464. * Sets the left trigger value
  38465. */
  38466. leftTrigger: number;
  38467. /**
  38468. * Gets the right trigger value
  38469. */
  38470. /**
  38471. * Sets the right trigger value
  38472. */
  38473. rightTrigger: number;
  38474. /**
  38475. * Defines the callback to call when a button is pressed
  38476. * @param callback defines the callback to use
  38477. */
  38478. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38479. /**
  38480. * Defines the callback to call when a button is released
  38481. * @param callback defines the callback to use
  38482. */
  38483. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38484. /**
  38485. * Defines the callback to call when a pad is pressed
  38486. * @param callback defines the callback to use
  38487. */
  38488. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38489. /**
  38490. * Defines the callback to call when a pad is released
  38491. * @param callback defines the callback to use
  38492. */
  38493. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38494. private _setButtonValue;
  38495. private _setDPadValue;
  38496. /**
  38497. * Gets the value of the `A` button
  38498. */
  38499. /**
  38500. * Sets the value of the `A` button
  38501. */
  38502. buttonA: number;
  38503. /**
  38504. * Gets the value of the `B` button
  38505. */
  38506. /**
  38507. * Sets the value of the `B` button
  38508. */
  38509. buttonB: number;
  38510. /**
  38511. * Gets the value of the `X` button
  38512. */
  38513. /**
  38514. * Sets the value of the `X` button
  38515. */
  38516. buttonX: number;
  38517. /**
  38518. * Gets the value of the `Y` button
  38519. */
  38520. /**
  38521. * Sets the value of the `Y` button
  38522. */
  38523. buttonY: number;
  38524. /**
  38525. * Gets the value of the `Start` button
  38526. */
  38527. /**
  38528. * Sets the value of the `Start` button
  38529. */
  38530. buttonStart: number;
  38531. /**
  38532. * Gets the value of the `Back` button
  38533. */
  38534. /**
  38535. * Sets the value of the `Back` button
  38536. */
  38537. buttonBack: number;
  38538. /**
  38539. * Gets the value of the `Left` button
  38540. */
  38541. /**
  38542. * Sets the value of the `Left` button
  38543. */
  38544. buttonLB: number;
  38545. /**
  38546. * Gets the value of the `Right` button
  38547. */
  38548. /**
  38549. * Sets the value of the `Right` button
  38550. */
  38551. buttonRB: number;
  38552. /**
  38553. * Gets the value of the Left joystick
  38554. */
  38555. /**
  38556. * Sets the value of the Left joystick
  38557. */
  38558. buttonLeftStick: number;
  38559. /**
  38560. * Gets the value of the Right joystick
  38561. */
  38562. /**
  38563. * Sets the value of the Right joystick
  38564. */
  38565. buttonRightStick: number;
  38566. /**
  38567. * Gets the value of D-pad up
  38568. */
  38569. /**
  38570. * Sets the value of D-pad up
  38571. */
  38572. dPadUp: number;
  38573. /**
  38574. * Gets the value of D-pad down
  38575. */
  38576. /**
  38577. * Sets the value of D-pad down
  38578. */
  38579. dPadDown: number;
  38580. /**
  38581. * Gets the value of D-pad left
  38582. */
  38583. /**
  38584. * Sets the value of D-pad left
  38585. */
  38586. dPadLeft: number;
  38587. /**
  38588. * Gets the value of D-pad right
  38589. */
  38590. /**
  38591. * Sets the value of D-pad right
  38592. */
  38593. dPadRight: number;
  38594. /**
  38595. * Force the gamepad to synchronize with device values
  38596. */
  38597. update(): void;
  38598. /**
  38599. * Disposes the gamepad
  38600. */
  38601. dispose(): void;
  38602. }
  38603. }
  38604. declare module BABYLON {
  38605. /**
  38606. * Defines supported buttons for DualShock compatible gamepads
  38607. */
  38608. export enum DualShockButton {
  38609. /** Cross */
  38610. Cross = 0,
  38611. /** Circle */
  38612. Circle = 1,
  38613. /** Square */
  38614. Square = 2,
  38615. /** Triangle */
  38616. Triangle = 3,
  38617. /** Options */
  38618. Options = 4,
  38619. /** Share */
  38620. Share = 5,
  38621. /** L1 */
  38622. L1 = 6,
  38623. /** R1 */
  38624. R1 = 7,
  38625. /** Left stick */
  38626. LeftStick = 8,
  38627. /** Right stick */
  38628. RightStick = 9
  38629. }
  38630. /** Defines values for DualShock DPad */
  38631. export enum DualShockDpad {
  38632. /** Up */
  38633. Up = 0,
  38634. /** Down */
  38635. Down = 1,
  38636. /** Left */
  38637. Left = 2,
  38638. /** Right */
  38639. Right = 3
  38640. }
  38641. /**
  38642. * Defines a DualShock gamepad
  38643. */
  38644. export class DualShockPad extends Gamepad {
  38645. private _leftTrigger;
  38646. private _rightTrigger;
  38647. private _onlefttriggerchanged;
  38648. private _onrighttriggerchanged;
  38649. private _onbuttondown;
  38650. private _onbuttonup;
  38651. private _ondpaddown;
  38652. private _ondpadup;
  38653. /** Observable raised when a button is pressed */
  38654. onButtonDownObservable: Observable<DualShockButton>;
  38655. /** Observable raised when a button is released */
  38656. onButtonUpObservable: Observable<DualShockButton>;
  38657. /** Observable raised when a pad is pressed */
  38658. onPadDownObservable: Observable<DualShockDpad>;
  38659. /** Observable raised when a pad is released */
  38660. onPadUpObservable: Observable<DualShockDpad>;
  38661. private _buttonCross;
  38662. private _buttonCircle;
  38663. private _buttonSquare;
  38664. private _buttonTriangle;
  38665. private _buttonShare;
  38666. private _buttonOptions;
  38667. private _buttonL1;
  38668. private _buttonR1;
  38669. private _buttonLeftStick;
  38670. private _buttonRightStick;
  38671. private _dPadUp;
  38672. private _dPadDown;
  38673. private _dPadLeft;
  38674. private _dPadRight;
  38675. /**
  38676. * Creates a new DualShock gamepad object
  38677. * @param id defines the id of this gamepad
  38678. * @param index defines its index
  38679. * @param gamepad defines the internal HTML gamepad object
  38680. */
  38681. constructor(id: string, index: number, gamepad: any);
  38682. /**
  38683. * Defines the callback to call when left trigger is pressed
  38684. * @param callback defines the callback to use
  38685. */
  38686. onlefttriggerchanged(callback: (value: number) => void): void;
  38687. /**
  38688. * Defines the callback to call when right trigger is pressed
  38689. * @param callback defines the callback to use
  38690. */
  38691. onrighttriggerchanged(callback: (value: number) => void): void;
  38692. /**
  38693. * Gets the left trigger value
  38694. */
  38695. /**
  38696. * Sets the left trigger value
  38697. */
  38698. leftTrigger: number;
  38699. /**
  38700. * Gets the right trigger value
  38701. */
  38702. /**
  38703. * Sets the right trigger value
  38704. */
  38705. rightTrigger: number;
  38706. /**
  38707. * Defines the callback to call when a button is pressed
  38708. * @param callback defines the callback to use
  38709. */
  38710. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38711. /**
  38712. * Defines the callback to call when a button is released
  38713. * @param callback defines the callback to use
  38714. */
  38715. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38716. /**
  38717. * Defines the callback to call when a pad is pressed
  38718. * @param callback defines the callback to use
  38719. */
  38720. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38721. /**
  38722. * Defines the callback to call when a pad is released
  38723. * @param callback defines the callback to use
  38724. */
  38725. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38726. private _setButtonValue;
  38727. private _setDPadValue;
  38728. /**
  38729. * Gets the value of the `Cross` button
  38730. */
  38731. /**
  38732. * Sets the value of the `Cross` button
  38733. */
  38734. buttonCross: number;
  38735. /**
  38736. * Gets the value of the `Circle` button
  38737. */
  38738. /**
  38739. * Sets the value of the `Circle` button
  38740. */
  38741. buttonCircle: number;
  38742. /**
  38743. * Gets the value of the `Square` button
  38744. */
  38745. /**
  38746. * Sets the value of the `Square` button
  38747. */
  38748. buttonSquare: number;
  38749. /**
  38750. * Gets the value of the `Triangle` button
  38751. */
  38752. /**
  38753. * Sets the value of the `Triangle` button
  38754. */
  38755. buttonTriangle: number;
  38756. /**
  38757. * Gets the value of the `Options` button
  38758. */
  38759. /**
  38760. * Sets the value of the `Options` button
  38761. */
  38762. buttonOptions: number;
  38763. /**
  38764. * Gets the value of the `Share` button
  38765. */
  38766. /**
  38767. * Sets the value of the `Share` button
  38768. */
  38769. buttonShare: number;
  38770. /**
  38771. * Gets the value of the `L1` button
  38772. */
  38773. /**
  38774. * Sets the value of the `L1` button
  38775. */
  38776. buttonL1: number;
  38777. /**
  38778. * Gets the value of the `R1` button
  38779. */
  38780. /**
  38781. * Sets the value of the `R1` button
  38782. */
  38783. buttonR1: number;
  38784. /**
  38785. * Gets the value of the Left joystick
  38786. */
  38787. /**
  38788. * Sets the value of the Left joystick
  38789. */
  38790. buttonLeftStick: number;
  38791. /**
  38792. * Gets the value of the Right joystick
  38793. */
  38794. /**
  38795. * Sets the value of the Right joystick
  38796. */
  38797. buttonRightStick: number;
  38798. /**
  38799. * Gets the value of D-pad up
  38800. */
  38801. /**
  38802. * Sets the value of D-pad up
  38803. */
  38804. dPadUp: number;
  38805. /**
  38806. * Gets the value of D-pad down
  38807. */
  38808. /**
  38809. * Sets the value of D-pad down
  38810. */
  38811. dPadDown: number;
  38812. /**
  38813. * Gets the value of D-pad left
  38814. */
  38815. /**
  38816. * Sets the value of D-pad left
  38817. */
  38818. dPadLeft: number;
  38819. /**
  38820. * Gets the value of D-pad right
  38821. */
  38822. /**
  38823. * Sets the value of D-pad right
  38824. */
  38825. dPadRight: number;
  38826. /**
  38827. * Force the gamepad to synchronize with device values
  38828. */
  38829. update(): void;
  38830. /**
  38831. * Disposes the gamepad
  38832. */
  38833. dispose(): void;
  38834. }
  38835. }
  38836. declare module BABYLON {
  38837. /**
  38838. * Manager for handling gamepads
  38839. */
  38840. export class GamepadManager {
  38841. private _scene?;
  38842. private _babylonGamepads;
  38843. private _oneGamepadConnected;
  38844. /** @hidden */
  38845. _isMonitoring: boolean;
  38846. private _gamepadEventSupported;
  38847. private _gamepadSupport;
  38848. /**
  38849. * observable to be triggered when the gamepad controller has been connected
  38850. */
  38851. onGamepadConnectedObservable: Observable<Gamepad>;
  38852. /**
  38853. * observable to be triggered when the gamepad controller has been disconnected
  38854. */
  38855. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38856. private _onGamepadConnectedEvent;
  38857. private _onGamepadDisconnectedEvent;
  38858. /**
  38859. * Initializes the gamepad manager
  38860. * @param _scene BabylonJS scene
  38861. */
  38862. constructor(_scene?: Scene | undefined);
  38863. /**
  38864. * The gamepads in the game pad manager
  38865. */
  38866. readonly gamepads: Gamepad[];
  38867. /**
  38868. * Get the gamepad controllers based on type
  38869. * @param type The type of gamepad controller
  38870. * @returns Nullable gamepad
  38871. */
  38872. getGamepadByType(type?: number): Nullable<Gamepad>;
  38873. /**
  38874. * Disposes the gamepad manager
  38875. */
  38876. dispose(): void;
  38877. private _addNewGamepad;
  38878. private _startMonitoringGamepads;
  38879. private _stopMonitoringGamepads;
  38880. /** @hidden */
  38881. _checkGamepadsStatus(): void;
  38882. private _updateGamepadObjects;
  38883. }
  38884. }
  38885. declare module BABYLON {
  38886. interface Scene {
  38887. /** @hidden */
  38888. _gamepadManager: Nullable<GamepadManager>;
  38889. /**
  38890. * Gets the gamepad manager associated with the scene
  38891. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38892. */
  38893. gamepadManager: GamepadManager;
  38894. }
  38895. /**
  38896. * Interface representing a free camera inputs manager
  38897. */
  38898. interface FreeCameraInputsManager {
  38899. /**
  38900. * Adds gamepad input support to the FreeCameraInputsManager.
  38901. * @returns the FreeCameraInputsManager
  38902. */
  38903. addGamepad(): FreeCameraInputsManager;
  38904. }
  38905. /**
  38906. * Interface representing an arc rotate camera inputs manager
  38907. */
  38908. interface ArcRotateCameraInputsManager {
  38909. /**
  38910. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38911. * @returns the camera inputs manager
  38912. */
  38913. addGamepad(): ArcRotateCameraInputsManager;
  38914. }
  38915. /**
  38916. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38917. */
  38918. export class GamepadSystemSceneComponent implements ISceneComponent {
  38919. /**
  38920. * The component name helpfull to identify the component in the list of scene components.
  38921. */
  38922. readonly name: string;
  38923. /**
  38924. * The scene the component belongs to.
  38925. */
  38926. scene: Scene;
  38927. /**
  38928. * Creates a new instance of the component for the given scene
  38929. * @param scene Defines the scene to register the component in
  38930. */
  38931. constructor(scene: Scene);
  38932. /**
  38933. * Registers the component in a given scene
  38934. */
  38935. register(): void;
  38936. /**
  38937. * Rebuilds the elements related to this component in case of
  38938. * context lost for instance.
  38939. */
  38940. rebuild(): void;
  38941. /**
  38942. * Disposes the component and the associated ressources
  38943. */
  38944. dispose(): void;
  38945. private _beforeCameraUpdate;
  38946. }
  38947. }
  38948. declare module BABYLON {
  38949. /**
  38950. * 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,
  38951. * which still works and will still be found in many Playgrounds.
  38952. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38953. */
  38954. export class UniversalCamera extends TouchCamera {
  38955. /**
  38956. * Defines the gamepad rotation sensiblity.
  38957. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38958. */
  38959. gamepadAngularSensibility: number;
  38960. /**
  38961. * Defines the gamepad move sensiblity.
  38962. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38963. */
  38964. gamepadMoveSensibility: number;
  38965. /**
  38966. * 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,
  38967. * which still works and will still be found in many Playgrounds.
  38968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38969. * @param name Define the name of the camera in the scene
  38970. * @param position Define the start position of the camera in the scene
  38971. * @param scene Define the scene the camera belongs to
  38972. */
  38973. constructor(name: string, position: Vector3, scene: Scene);
  38974. /**
  38975. * Gets the current object class name.
  38976. * @return the class name
  38977. */
  38978. getClassName(): string;
  38979. }
  38980. }
  38981. declare module BABYLON {
  38982. /**
  38983. * This represents a FPS type of camera. This is only here for back compat purpose.
  38984. * Please use the UniversalCamera instead as both are identical.
  38985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38986. */
  38987. export class GamepadCamera extends UniversalCamera {
  38988. /**
  38989. * Instantiates a new Gamepad Camera
  38990. * This represents a FPS type of camera. This is only here for back compat purpose.
  38991. * Please use the UniversalCamera instead as both are identical.
  38992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38993. * @param name Define the name of the camera in the scene
  38994. * @param position Define the start position of the camera in the scene
  38995. * @param scene Define the scene the camera belongs to
  38996. */
  38997. constructor(name: string, position: Vector3, scene: Scene);
  38998. /**
  38999. * Gets the current object class name.
  39000. * @return the class name
  39001. */
  39002. getClassName(): string;
  39003. }
  39004. }
  39005. declare module BABYLON {
  39006. /** @hidden */
  39007. export var passPixelShader: {
  39008. name: string;
  39009. shader: string;
  39010. };
  39011. }
  39012. declare module BABYLON {
  39013. /** @hidden */
  39014. export var passCubePixelShader: {
  39015. name: string;
  39016. shader: string;
  39017. };
  39018. }
  39019. declare module BABYLON {
  39020. /**
  39021. * PassPostProcess which produces an output the same as it's input
  39022. */
  39023. export class PassPostProcess extends PostProcess {
  39024. /**
  39025. * Creates the PassPostProcess
  39026. * @param name The name of the effect.
  39027. * @param options The required width/height ratio to downsize to before computing the render pass.
  39028. * @param camera The camera to apply the render pass to.
  39029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39030. * @param engine The engine which the post process will be applied. (default: current engine)
  39031. * @param reusable If the post process can be reused on the same frame. (default: false)
  39032. * @param textureType The type of texture to be used when performing the post processing.
  39033. * @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)
  39034. */
  39035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39036. }
  39037. /**
  39038. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39039. */
  39040. export class PassCubePostProcess extends PostProcess {
  39041. private _face;
  39042. /**
  39043. * Gets or sets the cube face to display.
  39044. * * 0 is +X
  39045. * * 1 is -X
  39046. * * 2 is +Y
  39047. * * 3 is -Y
  39048. * * 4 is +Z
  39049. * * 5 is -Z
  39050. */
  39051. face: number;
  39052. /**
  39053. * Creates the PassCubePostProcess
  39054. * @param name The name of the effect.
  39055. * @param options The required width/height ratio to downsize to before computing the render pass.
  39056. * @param camera The camera to apply the render pass to.
  39057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39058. * @param engine The engine which the post process will be applied. (default: current engine)
  39059. * @param reusable If the post process can be reused on the same frame. (default: false)
  39060. * @param textureType The type of texture to be used when performing the post processing.
  39061. * @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)
  39062. */
  39063. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39064. }
  39065. }
  39066. declare module BABYLON {
  39067. /** @hidden */
  39068. export var anaglyphPixelShader: {
  39069. name: string;
  39070. shader: string;
  39071. };
  39072. }
  39073. declare module BABYLON {
  39074. /**
  39075. * Postprocess used to generate anaglyphic rendering
  39076. */
  39077. export class AnaglyphPostProcess extends PostProcess {
  39078. private _passedProcess;
  39079. /**
  39080. * Creates a new AnaglyphPostProcess
  39081. * @param name defines postprocess name
  39082. * @param options defines creation options or target ratio scale
  39083. * @param rigCameras defines cameras using this postprocess
  39084. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39085. * @param engine defines hosting engine
  39086. * @param reusable defines if the postprocess will be reused multiple times per frame
  39087. */
  39088. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39089. }
  39090. }
  39091. declare module BABYLON {
  39092. /**
  39093. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39094. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39095. */
  39096. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39097. /**
  39098. * Creates a new AnaglyphArcRotateCamera
  39099. * @param name defines camera name
  39100. * @param alpha defines alpha angle (in radians)
  39101. * @param beta defines beta angle (in radians)
  39102. * @param radius defines radius
  39103. * @param target defines camera target
  39104. * @param interaxialDistance defines distance between each color axis
  39105. * @param scene defines the hosting scene
  39106. */
  39107. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39108. /**
  39109. * Gets camera class name
  39110. * @returns AnaglyphArcRotateCamera
  39111. */
  39112. getClassName(): string;
  39113. }
  39114. }
  39115. declare module BABYLON {
  39116. /**
  39117. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39118. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39119. */
  39120. export class AnaglyphFreeCamera extends FreeCamera {
  39121. /**
  39122. * Creates a new AnaglyphFreeCamera
  39123. * @param name defines camera name
  39124. * @param position defines initial position
  39125. * @param interaxialDistance defines distance between each color axis
  39126. * @param scene defines the hosting scene
  39127. */
  39128. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39129. /**
  39130. * Gets camera class name
  39131. * @returns AnaglyphFreeCamera
  39132. */
  39133. getClassName(): string;
  39134. }
  39135. }
  39136. declare module BABYLON {
  39137. /**
  39138. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39140. */
  39141. export class AnaglyphGamepadCamera extends GamepadCamera {
  39142. /**
  39143. * Creates a new AnaglyphGamepadCamera
  39144. * @param name defines camera name
  39145. * @param position defines initial position
  39146. * @param interaxialDistance defines distance between each color axis
  39147. * @param scene defines the hosting scene
  39148. */
  39149. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39150. /**
  39151. * Gets camera class name
  39152. * @returns AnaglyphGamepadCamera
  39153. */
  39154. getClassName(): string;
  39155. }
  39156. }
  39157. declare module BABYLON {
  39158. /**
  39159. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39160. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39161. */
  39162. export class AnaglyphUniversalCamera extends UniversalCamera {
  39163. /**
  39164. * Creates a new AnaglyphUniversalCamera
  39165. * @param name defines camera name
  39166. * @param position defines initial position
  39167. * @param interaxialDistance defines distance between each color axis
  39168. * @param scene defines the hosting scene
  39169. */
  39170. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39171. /**
  39172. * Gets camera class name
  39173. * @returns AnaglyphUniversalCamera
  39174. */
  39175. getClassName(): string;
  39176. }
  39177. }
  39178. declare module BABYLON {
  39179. /** @hidden */
  39180. export var stereoscopicInterlacePixelShader: {
  39181. name: string;
  39182. shader: string;
  39183. };
  39184. }
  39185. declare module BABYLON {
  39186. /**
  39187. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39188. */
  39189. export class StereoscopicInterlacePostProcess extends PostProcess {
  39190. private _stepSize;
  39191. private _passedProcess;
  39192. /**
  39193. * Initializes a StereoscopicInterlacePostProcess
  39194. * @param name The name of the effect.
  39195. * @param rigCameras The rig cameras to be appled to the post process
  39196. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39198. * @param engine The engine which the post process will be applied. (default: current engine)
  39199. * @param reusable If the post process can be reused on the same frame. (default: false)
  39200. */
  39201. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39202. }
  39203. }
  39204. declare module BABYLON {
  39205. /**
  39206. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39207. * @see http://doc.babylonjs.com/features/cameras
  39208. */
  39209. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39210. /**
  39211. * Creates a new StereoscopicArcRotateCamera
  39212. * @param name defines camera name
  39213. * @param alpha defines alpha angle (in radians)
  39214. * @param beta defines beta angle (in radians)
  39215. * @param radius defines radius
  39216. * @param target defines camera target
  39217. * @param interaxialDistance defines distance between each color axis
  39218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39219. * @param scene defines the hosting scene
  39220. */
  39221. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39222. /**
  39223. * Gets camera class name
  39224. * @returns StereoscopicArcRotateCamera
  39225. */
  39226. getClassName(): string;
  39227. }
  39228. }
  39229. declare module BABYLON {
  39230. /**
  39231. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39232. * @see http://doc.babylonjs.com/features/cameras
  39233. */
  39234. export class StereoscopicFreeCamera extends FreeCamera {
  39235. /**
  39236. * Creates a new StereoscopicFreeCamera
  39237. * @param name defines camera name
  39238. * @param position defines initial position
  39239. * @param interaxialDistance defines distance between each color axis
  39240. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39241. * @param scene defines the hosting scene
  39242. */
  39243. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39244. /**
  39245. * Gets camera class name
  39246. * @returns StereoscopicFreeCamera
  39247. */
  39248. getClassName(): string;
  39249. }
  39250. }
  39251. declare module BABYLON {
  39252. /**
  39253. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39254. * @see http://doc.babylonjs.com/features/cameras
  39255. */
  39256. export class StereoscopicGamepadCamera extends GamepadCamera {
  39257. /**
  39258. * Creates a new StereoscopicGamepadCamera
  39259. * @param name defines camera name
  39260. * @param position defines initial position
  39261. * @param interaxialDistance defines distance between each color axis
  39262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39263. * @param scene defines the hosting scene
  39264. */
  39265. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39266. /**
  39267. * Gets camera class name
  39268. * @returns StereoscopicGamepadCamera
  39269. */
  39270. getClassName(): string;
  39271. }
  39272. }
  39273. declare module BABYLON {
  39274. /**
  39275. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39276. * @see http://doc.babylonjs.com/features/cameras
  39277. */
  39278. export class StereoscopicUniversalCamera extends UniversalCamera {
  39279. /**
  39280. * Creates a new StereoscopicUniversalCamera
  39281. * @param name defines camera name
  39282. * @param position defines initial position
  39283. * @param interaxialDistance defines distance between each color axis
  39284. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39285. * @param scene defines the hosting scene
  39286. */
  39287. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39288. /**
  39289. * Gets camera class name
  39290. * @returns StereoscopicUniversalCamera
  39291. */
  39292. getClassName(): string;
  39293. }
  39294. }
  39295. declare module BABYLON {
  39296. /**
  39297. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39298. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39299. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39300. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39301. */
  39302. export class VirtualJoysticksCamera extends FreeCamera {
  39303. /**
  39304. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39305. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39306. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39307. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39308. * @param name Define the name of the camera in the scene
  39309. * @param position Define the start position of the camera in the scene
  39310. * @param scene Define the scene the camera belongs to
  39311. */
  39312. constructor(name: string, position: Vector3, scene: Scene);
  39313. /**
  39314. * Gets the current object class name.
  39315. * @return the class name
  39316. */
  39317. getClassName(): string;
  39318. }
  39319. }
  39320. declare module BABYLON {
  39321. /**
  39322. * This represents all the required metrics to create a VR camera.
  39323. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39324. */
  39325. export class VRCameraMetrics {
  39326. /**
  39327. * Define the horizontal resolution off the screen.
  39328. */
  39329. hResolution: number;
  39330. /**
  39331. * Define the vertical resolution off the screen.
  39332. */
  39333. vResolution: number;
  39334. /**
  39335. * Define the horizontal screen size.
  39336. */
  39337. hScreenSize: number;
  39338. /**
  39339. * Define the vertical screen size.
  39340. */
  39341. vScreenSize: number;
  39342. /**
  39343. * Define the vertical screen center position.
  39344. */
  39345. vScreenCenter: number;
  39346. /**
  39347. * Define the distance of the eyes to the screen.
  39348. */
  39349. eyeToScreenDistance: number;
  39350. /**
  39351. * Define the distance between both lenses
  39352. */
  39353. lensSeparationDistance: number;
  39354. /**
  39355. * Define the distance between both viewer's eyes.
  39356. */
  39357. interpupillaryDistance: number;
  39358. /**
  39359. * Define the distortion factor of the VR postprocess.
  39360. * Please, touch with care.
  39361. */
  39362. distortionK: number[];
  39363. /**
  39364. * Define the chromatic aberration correction factors for the VR post process.
  39365. */
  39366. chromaAbCorrection: number[];
  39367. /**
  39368. * Define the scale factor of the post process.
  39369. * The smaller the better but the slower.
  39370. */
  39371. postProcessScaleFactor: number;
  39372. /**
  39373. * Define an offset for the lens center.
  39374. */
  39375. lensCenterOffset: number;
  39376. /**
  39377. * Define if the current vr camera should compensate the distortion of the lense or not.
  39378. */
  39379. compensateDistortion: boolean;
  39380. /**
  39381. * Defines if multiview should be enabled when rendering (Default: false)
  39382. */
  39383. multiviewEnabled: boolean;
  39384. /**
  39385. * Gets the rendering aspect ratio based on the provided resolutions.
  39386. */
  39387. readonly aspectRatio: number;
  39388. /**
  39389. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39390. */
  39391. readonly aspectRatioFov: number;
  39392. /**
  39393. * @hidden
  39394. */
  39395. readonly leftHMatrix: Matrix;
  39396. /**
  39397. * @hidden
  39398. */
  39399. readonly rightHMatrix: Matrix;
  39400. /**
  39401. * @hidden
  39402. */
  39403. readonly leftPreViewMatrix: Matrix;
  39404. /**
  39405. * @hidden
  39406. */
  39407. readonly rightPreViewMatrix: Matrix;
  39408. /**
  39409. * Get the default VRMetrics based on the most generic setup.
  39410. * @returns the default vr metrics
  39411. */
  39412. static GetDefault(): VRCameraMetrics;
  39413. }
  39414. }
  39415. declare module BABYLON {
  39416. /** @hidden */
  39417. export var vrDistortionCorrectionPixelShader: {
  39418. name: string;
  39419. shader: string;
  39420. };
  39421. }
  39422. declare module BABYLON {
  39423. /**
  39424. * VRDistortionCorrectionPostProcess used for mobile VR
  39425. */
  39426. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39427. private _isRightEye;
  39428. private _distortionFactors;
  39429. private _postProcessScaleFactor;
  39430. private _lensCenterOffset;
  39431. private _scaleIn;
  39432. private _scaleFactor;
  39433. private _lensCenter;
  39434. /**
  39435. * Initializes the VRDistortionCorrectionPostProcess
  39436. * @param name The name of the effect.
  39437. * @param camera The camera to apply the render pass to.
  39438. * @param isRightEye If this is for the right eye distortion
  39439. * @param vrMetrics All the required metrics for the VR camera
  39440. */
  39441. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39442. }
  39443. }
  39444. declare module BABYLON {
  39445. /**
  39446. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39447. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39448. */
  39449. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39450. /**
  39451. * Creates a new VRDeviceOrientationArcRotateCamera
  39452. * @param name defines camera name
  39453. * @param alpha defines the camera rotation along the logitudinal axis
  39454. * @param beta defines the camera rotation along the latitudinal axis
  39455. * @param radius defines the camera distance from its target
  39456. * @param target defines the camera target
  39457. * @param scene defines the scene the camera belongs to
  39458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39460. */
  39461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39462. /**
  39463. * Gets camera class name
  39464. * @returns VRDeviceOrientationArcRotateCamera
  39465. */
  39466. getClassName(): string;
  39467. }
  39468. }
  39469. declare module BABYLON {
  39470. /**
  39471. * Camera used to simulate VR rendering (based on FreeCamera)
  39472. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39473. */
  39474. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39475. /**
  39476. * Creates a new VRDeviceOrientationFreeCamera
  39477. * @param name defines camera name
  39478. * @param position defines the start position of the camera
  39479. * @param scene defines the scene the camera belongs to
  39480. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39481. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39482. */
  39483. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39484. /**
  39485. * Gets camera class name
  39486. * @returns VRDeviceOrientationFreeCamera
  39487. */
  39488. getClassName(): string;
  39489. }
  39490. }
  39491. declare module BABYLON {
  39492. /**
  39493. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39494. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39495. */
  39496. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39497. /**
  39498. * Creates a new VRDeviceOrientationGamepadCamera
  39499. * @param name defines camera name
  39500. * @param position defines the start position of the camera
  39501. * @param scene defines the scene the camera belongs to
  39502. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39503. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39504. */
  39505. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39506. /**
  39507. * Gets camera class name
  39508. * @returns VRDeviceOrientationGamepadCamera
  39509. */
  39510. getClassName(): string;
  39511. }
  39512. }
  39513. declare module BABYLON {
  39514. /**
  39515. * Base class of materials working in push mode in babylon JS
  39516. * @hidden
  39517. */
  39518. export class PushMaterial extends Material {
  39519. protected _activeEffect: Effect;
  39520. protected _normalMatrix: Matrix;
  39521. /**
  39522. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39523. * This means that the material can keep using a previous shader while a new one is being compiled.
  39524. * This is mostly used when shader parallel compilation is supported (true by default)
  39525. */
  39526. allowShaderHotSwapping: boolean;
  39527. constructor(name: string, scene: Scene);
  39528. getEffect(): Effect;
  39529. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39530. /**
  39531. * Binds the given world matrix to the active effect
  39532. *
  39533. * @param world the matrix to bind
  39534. */
  39535. bindOnlyWorldMatrix(world: Matrix): void;
  39536. /**
  39537. * Binds the given normal matrix to the active effect
  39538. *
  39539. * @param normalMatrix the matrix to bind
  39540. */
  39541. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39542. bind(world: Matrix, mesh?: Mesh): void;
  39543. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39544. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39545. }
  39546. }
  39547. declare module BABYLON {
  39548. /**
  39549. * This groups all the flags used to control the materials channel.
  39550. */
  39551. export class MaterialFlags {
  39552. private static _DiffuseTextureEnabled;
  39553. /**
  39554. * Are diffuse textures enabled in the application.
  39555. */
  39556. static DiffuseTextureEnabled: boolean;
  39557. private static _AmbientTextureEnabled;
  39558. /**
  39559. * Are ambient textures enabled in the application.
  39560. */
  39561. static AmbientTextureEnabled: boolean;
  39562. private static _OpacityTextureEnabled;
  39563. /**
  39564. * Are opacity textures enabled in the application.
  39565. */
  39566. static OpacityTextureEnabled: boolean;
  39567. private static _ReflectionTextureEnabled;
  39568. /**
  39569. * Are reflection textures enabled in the application.
  39570. */
  39571. static ReflectionTextureEnabled: boolean;
  39572. private static _EmissiveTextureEnabled;
  39573. /**
  39574. * Are emissive textures enabled in the application.
  39575. */
  39576. static EmissiveTextureEnabled: boolean;
  39577. private static _SpecularTextureEnabled;
  39578. /**
  39579. * Are specular textures enabled in the application.
  39580. */
  39581. static SpecularTextureEnabled: boolean;
  39582. private static _BumpTextureEnabled;
  39583. /**
  39584. * Are bump textures enabled in the application.
  39585. */
  39586. static BumpTextureEnabled: boolean;
  39587. private static _LightmapTextureEnabled;
  39588. /**
  39589. * Are lightmap textures enabled in the application.
  39590. */
  39591. static LightmapTextureEnabled: boolean;
  39592. private static _RefractionTextureEnabled;
  39593. /**
  39594. * Are refraction textures enabled in the application.
  39595. */
  39596. static RefractionTextureEnabled: boolean;
  39597. private static _ColorGradingTextureEnabled;
  39598. /**
  39599. * Are color grading textures enabled in the application.
  39600. */
  39601. static ColorGradingTextureEnabled: boolean;
  39602. private static _FresnelEnabled;
  39603. /**
  39604. * Are fresnels enabled in the application.
  39605. */
  39606. static FresnelEnabled: boolean;
  39607. private static _ClearCoatTextureEnabled;
  39608. /**
  39609. * Are clear coat textures enabled in the application.
  39610. */
  39611. static ClearCoatTextureEnabled: boolean;
  39612. private static _ClearCoatBumpTextureEnabled;
  39613. /**
  39614. * Are clear coat bump textures enabled in the application.
  39615. */
  39616. static ClearCoatBumpTextureEnabled: boolean;
  39617. private static _ClearCoatTintTextureEnabled;
  39618. /**
  39619. * Are clear coat tint textures enabled in the application.
  39620. */
  39621. static ClearCoatTintTextureEnabled: boolean;
  39622. private static _SheenTextureEnabled;
  39623. /**
  39624. * Are sheen textures enabled in the application.
  39625. */
  39626. static SheenTextureEnabled: boolean;
  39627. private static _AnisotropicTextureEnabled;
  39628. /**
  39629. * Are anisotropic textures enabled in the application.
  39630. */
  39631. static AnisotropicTextureEnabled: boolean;
  39632. private static _ThicknessTextureEnabled;
  39633. /**
  39634. * Are thickness textures enabled in the application.
  39635. */
  39636. static ThicknessTextureEnabled: boolean;
  39637. }
  39638. }
  39639. declare module BABYLON {
  39640. /** @hidden */
  39641. export var defaultFragmentDeclaration: {
  39642. name: string;
  39643. shader: string;
  39644. };
  39645. }
  39646. declare module BABYLON {
  39647. /** @hidden */
  39648. export var defaultUboDeclaration: {
  39649. name: string;
  39650. shader: string;
  39651. };
  39652. }
  39653. declare module BABYLON {
  39654. /** @hidden */
  39655. export var lightFragmentDeclaration: {
  39656. name: string;
  39657. shader: string;
  39658. };
  39659. }
  39660. declare module BABYLON {
  39661. /** @hidden */
  39662. export var lightUboDeclaration: {
  39663. name: string;
  39664. shader: string;
  39665. };
  39666. }
  39667. declare module BABYLON {
  39668. /** @hidden */
  39669. export var lightsFragmentFunctions: {
  39670. name: string;
  39671. shader: string;
  39672. };
  39673. }
  39674. declare module BABYLON {
  39675. /** @hidden */
  39676. export var shadowsFragmentFunctions: {
  39677. name: string;
  39678. shader: string;
  39679. };
  39680. }
  39681. declare module BABYLON {
  39682. /** @hidden */
  39683. export var fresnelFunction: {
  39684. name: string;
  39685. shader: string;
  39686. };
  39687. }
  39688. declare module BABYLON {
  39689. /** @hidden */
  39690. export var reflectionFunction: {
  39691. name: string;
  39692. shader: string;
  39693. };
  39694. }
  39695. declare module BABYLON {
  39696. /** @hidden */
  39697. export var bumpFragmentFunctions: {
  39698. name: string;
  39699. shader: string;
  39700. };
  39701. }
  39702. declare module BABYLON {
  39703. /** @hidden */
  39704. export var logDepthDeclaration: {
  39705. name: string;
  39706. shader: string;
  39707. };
  39708. }
  39709. declare module BABYLON {
  39710. /** @hidden */
  39711. export var bumpFragment: {
  39712. name: string;
  39713. shader: string;
  39714. };
  39715. }
  39716. declare module BABYLON {
  39717. /** @hidden */
  39718. export var depthPrePass: {
  39719. name: string;
  39720. shader: string;
  39721. };
  39722. }
  39723. declare module BABYLON {
  39724. /** @hidden */
  39725. export var lightFragment: {
  39726. name: string;
  39727. shader: string;
  39728. };
  39729. }
  39730. declare module BABYLON {
  39731. /** @hidden */
  39732. export var logDepthFragment: {
  39733. name: string;
  39734. shader: string;
  39735. };
  39736. }
  39737. declare module BABYLON {
  39738. /** @hidden */
  39739. export var defaultPixelShader: {
  39740. name: string;
  39741. shader: string;
  39742. };
  39743. }
  39744. declare module BABYLON {
  39745. /** @hidden */
  39746. export var defaultVertexDeclaration: {
  39747. name: string;
  39748. shader: string;
  39749. };
  39750. }
  39751. declare module BABYLON {
  39752. /** @hidden */
  39753. export var bumpVertexDeclaration: {
  39754. name: string;
  39755. shader: string;
  39756. };
  39757. }
  39758. declare module BABYLON {
  39759. /** @hidden */
  39760. export var bumpVertex: {
  39761. name: string;
  39762. shader: string;
  39763. };
  39764. }
  39765. declare module BABYLON {
  39766. /** @hidden */
  39767. export var fogVertex: {
  39768. name: string;
  39769. shader: string;
  39770. };
  39771. }
  39772. declare module BABYLON {
  39773. /** @hidden */
  39774. export var shadowsVertex: {
  39775. name: string;
  39776. shader: string;
  39777. };
  39778. }
  39779. declare module BABYLON {
  39780. /** @hidden */
  39781. export var pointCloudVertex: {
  39782. name: string;
  39783. shader: string;
  39784. };
  39785. }
  39786. declare module BABYLON {
  39787. /** @hidden */
  39788. export var logDepthVertex: {
  39789. name: string;
  39790. shader: string;
  39791. };
  39792. }
  39793. declare module BABYLON {
  39794. /** @hidden */
  39795. export var defaultVertexShader: {
  39796. name: string;
  39797. shader: string;
  39798. };
  39799. }
  39800. declare module BABYLON {
  39801. /** @hidden */
  39802. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39803. MAINUV1: boolean;
  39804. MAINUV2: boolean;
  39805. DIFFUSE: boolean;
  39806. DIFFUSEDIRECTUV: number;
  39807. AMBIENT: boolean;
  39808. AMBIENTDIRECTUV: number;
  39809. OPACITY: boolean;
  39810. OPACITYDIRECTUV: number;
  39811. OPACITYRGB: boolean;
  39812. REFLECTION: boolean;
  39813. EMISSIVE: boolean;
  39814. EMISSIVEDIRECTUV: number;
  39815. SPECULAR: boolean;
  39816. SPECULARDIRECTUV: number;
  39817. BUMP: boolean;
  39818. BUMPDIRECTUV: number;
  39819. PARALLAX: boolean;
  39820. PARALLAXOCCLUSION: boolean;
  39821. SPECULAROVERALPHA: boolean;
  39822. CLIPPLANE: boolean;
  39823. CLIPPLANE2: boolean;
  39824. CLIPPLANE3: boolean;
  39825. CLIPPLANE4: boolean;
  39826. ALPHATEST: boolean;
  39827. DEPTHPREPASS: boolean;
  39828. ALPHAFROMDIFFUSE: boolean;
  39829. POINTSIZE: boolean;
  39830. FOG: boolean;
  39831. SPECULARTERM: boolean;
  39832. DIFFUSEFRESNEL: boolean;
  39833. OPACITYFRESNEL: boolean;
  39834. REFLECTIONFRESNEL: boolean;
  39835. REFRACTIONFRESNEL: boolean;
  39836. EMISSIVEFRESNEL: boolean;
  39837. FRESNEL: boolean;
  39838. NORMAL: boolean;
  39839. UV1: boolean;
  39840. UV2: boolean;
  39841. VERTEXCOLOR: boolean;
  39842. VERTEXALPHA: boolean;
  39843. NUM_BONE_INFLUENCERS: number;
  39844. BonesPerMesh: number;
  39845. BONETEXTURE: boolean;
  39846. INSTANCES: boolean;
  39847. GLOSSINESS: boolean;
  39848. ROUGHNESS: boolean;
  39849. EMISSIVEASILLUMINATION: boolean;
  39850. LINKEMISSIVEWITHDIFFUSE: boolean;
  39851. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39852. LIGHTMAP: boolean;
  39853. LIGHTMAPDIRECTUV: number;
  39854. OBJECTSPACE_NORMALMAP: boolean;
  39855. USELIGHTMAPASSHADOWMAP: boolean;
  39856. REFLECTIONMAP_3D: boolean;
  39857. REFLECTIONMAP_SPHERICAL: boolean;
  39858. REFLECTIONMAP_PLANAR: boolean;
  39859. REFLECTIONMAP_CUBIC: boolean;
  39860. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39861. REFLECTIONMAP_PROJECTION: boolean;
  39862. REFLECTIONMAP_SKYBOX: boolean;
  39863. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39864. REFLECTIONMAP_EXPLICIT: boolean;
  39865. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39866. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39867. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39868. INVERTCUBICMAP: boolean;
  39869. LOGARITHMICDEPTH: boolean;
  39870. REFRACTION: boolean;
  39871. REFRACTIONMAP_3D: boolean;
  39872. REFLECTIONOVERALPHA: boolean;
  39873. TWOSIDEDLIGHTING: boolean;
  39874. SHADOWFLOAT: boolean;
  39875. MORPHTARGETS: boolean;
  39876. MORPHTARGETS_NORMAL: boolean;
  39877. MORPHTARGETS_TANGENT: boolean;
  39878. MORPHTARGETS_UV: boolean;
  39879. NUM_MORPH_INFLUENCERS: number;
  39880. NONUNIFORMSCALING: boolean;
  39881. PREMULTIPLYALPHA: boolean;
  39882. IMAGEPROCESSING: boolean;
  39883. VIGNETTE: boolean;
  39884. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39885. VIGNETTEBLENDMODEOPAQUE: boolean;
  39886. TONEMAPPING: boolean;
  39887. TONEMAPPING_ACES: boolean;
  39888. CONTRAST: boolean;
  39889. COLORCURVES: boolean;
  39890. COLORGRADING: boolean;
  39891. COLORGRADING3D: boolean;
  39892. SAMPLER3DGREENDEPTH: boolean;
  39893. SAMPLER3DBGRMAP: boolean;
  39894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39895. MULTIVIEW: boolean;
  39896. /**
  39897. * If the reflection texture on this material is in linear color space
  39898. * @hidden
  39899. */
  39900. IS_REFLECTION_LINEAR: boolean;
  39901. /**
  39902. * If the refraction texture on this material is in linear color space
  39903. * @hidden
  39904. */
  39905. IS_REFRACTION_LINEAR: boolean;
  39906. EXPOSURE: boolean;
  39907. constructor();
  39908. setReflectionMode(modeToEnable: string): void;
  39909. }
  39910. /**
  39911. * This is the default material used in Babylon. It is the best trade off between quality
  39912. * and performances.
  39913. * @see http://doc.babylonjs.com/babylon101/materials
  39914. */
  39915. export class StandardMaterial extends PushMaterial {
  39916. private _diffuseTexture;
  39917. /**
  39918. * The basic texture of the material as viewed under a light.
  39919. */
  39920. diffuseTexture: Nullable<BaseTexture>;
  39921. private _ambientTexture;
  39922. /**
  39923. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39924. */
  39925. ambientTexture: Nullable<BaseTexture>;
  39926. private _opacityTexture;
  39927. /**
  39928. * Define the transparency of the material from a texture.
  39929. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39930. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39931. */
  39932. opacityTexture: Nullable<BaseTexture>;
  39933. private _reflectionTexture;
  39934. /**
  39935. * Define the texture used to display the reflection.
  39936. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39937. */
  39938. reflectionTexture: Nullable<BaseTexture>;
  39939. private _emissiveTexture;
  39940. /**
  39941. * Define texture of the material as if self lit.
  39942. * This will be mixed in the final result even in the absence of light.
  39943. */
  39944. emissiveTexture: Nullable<BaseTexture>;
  39945. private _specularTexture;
  39946. /**
  39947. * Define how the color and intensity of the highlight given by the light in the material.
  39948. */
  39949. specularTexture: Nullable<BaseTexture>;
  39950. private _bumpTexture;
  39951. /**
  39952. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39953. * 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.
  39954. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39955. */
  39956. bumpTexture: Nullable<BaseTexture>;
  39957. private _lightmapTexture;
  39958. /**
  39959. * Complex lighting can be computationally expensive to compute at runtime.
  39960. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39961. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39962. */
  39963. lightmapTexture: Nullable<BaseTexture>;
  39964. private _refractionTexture;
  39965. /**
  39966. * Define the texture used to display the refraction.
  39967. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39968. */
  39969. refractionTexture: Nullable<BaseTexture>;
  39970. /**
  39971. * The color of the material lit by the environmental background lighting.
  39972. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39973. */
  39974. ambientColor: Color3;
  39975. /**
  39976. * The basic color of the material as viewed under a light.
  39977. */
  39978. diffuseColor: Color3;
  39979. /**
  39980. * Define how the color and intensity of the highlight given by the light in the material.
  39981. */
  39982. specularColor: Color3;
  39983. /**
  39984. * Define the color of the material as if self lit.
  39985. * This will be mixed in the final result even in the absence of light.
  39986. */
  39987. emissiveColor: Color3;
  39988. /**
  39989. * Defines how sharp are the highlights in the material.
  39990. * The bigger the value the sharper giving a more glossy feeling to the result.
  39991. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39992. */
  39993. specularPower: number;
  39994. private _useAlphaFromDiffuseTexture;
  39995. /**
  39996. * Does the transparency come from the diffuse texture alpha channel.
  39997. */
  39998. useAlphaFromDiffuseTexture: boolean;
  39999. private _useEmissiveAsIllumination;
  40000. /**
  40001. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40002. */
  40003. useEmissiveAsIllumination: boolean;
  40004. private _linkEmissiveWithDiffuse;
  40005. /**
  40006. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40007. * the emissive level when the final color is close to one.
  40008. */
  40009. linkEmissiveWithDiffuse: boolean;
  40010. private _useSpecularOverAlpha;
  40011. /**
  40012. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40013. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40014. */
  40015. useSpecularOverAlpha: boolean;
  40016. private _useReflectionOverAlpha;
  40017. /**
  40018. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40019. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40020. */
  40021. useReflectionOverAlpha: boolean;
  40022. private _disableLighting;
  40023. /**
  40024. * Does lights from the scene impacts this material.
  40025. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40026. */
  40027. disableLighting: boolean;
  40028. private _useObjectSpaceNormalMap;
  40029. /**
  40030. * Allows using an object space normal map (instead of tangent space).
  40031. */
  40032. useObjectSpaceNormalMap: boolean;
  40033. private _useParallax;
  40034. /**
  40035. * Is parallax enabled or not.
  40036. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40037. */
  40038. useParallax: boolean;
  40039. private _useParallaxOcclusion;
  40040. /**
  40041. * Is parallax occlusion enabled or not.
  40042. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40043. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40044. */
  40045. useParallaxOcclusion: boolean;
  40046. /**
  40047. * 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.
  40048. */
  40049. parallaxScaleBias: number;
  40050. private _roughness;
  40051. /**
  40052. * Helps to define how blurry the reflections should appears in the material.
  40053. */
  40054. roughness: number;
  40055. /**
  40056. * In case of refraction, define the value of the index of refraction.
  40057. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40058. */
  40059. indexOfRefraction: number;
  40060. /**
  40061. * Invert the refraction texture alongside the y axis.
  40062. * It can be useful with procedural textures or probe for instance.
  40063. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40064. */
  40065. invertRefractionY: boolean;
  40066. /**
  40067. * Defines the alpha limits in alpha test mode.
  40068. */
  40069. alphaCutOff: number;
  40070. private _useLightmapAsShadowmap;
  40071. /**
  40072. * In case of light mapping, define whether the map contains light or shadow informations.
  40073. */
  40074. useLightmapAsShadowmap: boolean;
  40075. private _diffuseFresnelParameters;
  40076. /**
  40077. * Define the diffuse fresnel parameters of the material.
  40078. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40079. */
  40080. diffuseFresnelParameters: FresnelParameters;
  40081. private _opacityFresnelParameters;
  40082. /**
  40083. * Define the opacity fresnel parameters of the material.
  40084. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40085. */
  40086. opacityFresnelParameters: FresnelParameters;
  40087. private _reflectionFresnelParameters;
  40088. /**
  40089. * Define the reflection fresnel parameters of the material.
  40090. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40091. */
  40092. reflectionFresnelParameters: FresnelParameters;
  40093. private _refractionFresnelParameters;
  40094. /**
  40095. * Define the refraction fresnel parameters of the material.
  40096. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40097. */
  40098. refractionFresnelParameters: FresnelParameters;
  40099. private _emissiveFresnelParameters;
  40100. /**
  40101. * Define the emissive fresnel parameters of the material.
  40102. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40103. */
  40104. emissiveFresnelParameters: FresnelParameters;
  40105. private _useReflectionFresnelFromSpecular;
  40106. /**
  40107. * If true automatically deducts the fresnels values from the material specularity.
  40108. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40109. */
  40110. useReflectionFresnelFromSpecular: boolean;
  40111. private _useGlossinessFromSpecularMapAlpha;
  40112. /**
  40113. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40114. */
  40115. useGlossinessFromSpecularMapAlpha: boolean;
  40116. private _maxSimultaneousLights;
  40117. /**
  40118. * Defines the maximum number of lights that can be used in the material
  40119. */
  40120. maxSimultaneousLights: number;
  40121. private _invertNormalMapX;
  40122. /**
  40123. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40124. */
  40125. invertNormalMapX: boolean;
  40126. private _invertNormalMapY;
  40127. /**
  40128. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40129. */
  40130. invertNormalMapY: boolean;
  40131. private _twoSidedLighting;
  40132. /**
  40133. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40134. */
  40135. twoSidedLighting: boolean;
  40136. /**
  40137. * Default configuration related to image processing available in the standard Material.
  40138. */
  40139. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40140. /**
  40141. * Gets the image processing configuration used either in this material.
  40142. */
  40143. /**
  40144. * Sets the Default image processing configuration used either in the this material.
  40145. *
  40146. * If sets to null, the scene one is in use.
  40147. */
  40148. imageProcessingConfiguration: ImageProcessingConfiguration;
  40149. /**
  40150. * Keep track of the image processing observer to allow dispose and replace.
  40151. */
  40152. private _imageProcessingObserver;
  40153. /**
  40154. * Attaches a new image processing configuration to the Standard Material.
  40155. * @param configuration
  40156. */
  40157. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40158. /**
  40159. * Gets wether the color curves effect is enabled.
  40160. */
  40161. /**
  40162. * Sets wether the color curves effect is enabled.
  40163. */
  40164. cameraColorCurvesEnabled: boolean;
  40165. /**
  40166. * Gets wether the color grading effect is enabled.
  40167. */
  40168. /**
  40169. * Gets wether the color grading effect is enabled.
  40170. */
  40171. cameraColorGradingEnabled: boolean;
  40172. /**
  40173. * Gets wether tonemapping is enabled or not.
  40174. */
  40175. /**
  40176. * Sets wether tonemapping is enabled or not
  40177. */
  40178. cameraToneMappingEnabled: boolean;
  40179. /**
  40180. * The camera exposure used on this material.
  40181. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40182. * This corresponds to a photographic exposure.
  40183. */
  40184. /**
  40185. * The camera exposure used on this material.
  40186. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40187. * This corresponds to a photographic exposure.
  40188. */
  40189. cameraExposure: number;
  40190. /**
  40191. * Gets The camera contrast used on this material.
  40192. */
  40193. /**
  40194. * Sets The camera contrast used on this material.
  40195. */
  40196. cameraContrast: number;
  40197. /**
  40198. * Gets the Color Grading 2D Lookup Texture.
  40199. */
  40200. /**
  40201. * Sets the Color Grading 2D Lookup Texture.
  40202. */
  40203. cameraColorGradingTexture: Nullable<BaseTexture>;
  40204. /**
  40205. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40206. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40207. * 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;
  40208. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40209. */
  40210. /**
  40211. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40212. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40213. * 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;
  40214. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40215. */
  40216. cameraColorCurves: Nullable<ColorCurves>;
  40217. /**
  40218. * Custom callback helping to override the default shader used in the material.
  40219. */
  40220. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40221. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40222. protected _worldViewProjectionMatrix: Matrix;
  40223. protected _globalAmbientColor: Color3;
  40224. protected _useLogarithmicDepth: boolean;
  40225. protected _rebuildInParallel: boolean;
  40226. /**
  40227. * Instantiates a new standard material.
  40228. * This is the default material used in Babylon. It is the best trade off between quality
  40229. * and performances.
  40230. * @see http://doc.babylonjs.com/babylon101/materials
  40231. * @param name Define the name of the material in the scene
  40232. * @param scene Define the scene the material belong to
  40233. */
  40234. constructor(name: string, scene: Scene);
  40235. /**
  40236. * Gets a boolean indicating that current material needs to register RTT
  40237. */
  40238. readonly hasRenderTargetTextures: boolean;
  40239. /**
  40240. * Gets the current class name of the material e.g. "StandardMaterial"
  40241. * Mainly use in serialization.
  40242. * @returns the class name
  40243. */
  40244. getClassName(): string;
  40245. /**
  40246. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40247. * You can try switching to logarithmic depth.
  40248. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40249. */
  40250. useLogarithmicDepth: boolean;
  40251. /**
  40252. * Specifies if the material will require alpha blending
  40253. * @returns a boolean specifying if alpha blending is needed
  40254. */
  40255. needAlphaBlending(): boolean;
  40256. /**
  40257. * Specifies if this material should be rendered in alpha test mode
  40258. * @returns a boolean specifying if an alpha test is needed.
  40259. */
  40260. needAlphaTesting(): boolean;
  40261. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40262. /**
  40263. * Get the texture used for alpha test purpose.
  40264. * @returns the diffuse texture in case of the standard material.
  40265. */
  40266. getAlphaTestTexture(): Nullable<BaseTexture>;
  40267. /**
  40268. * Get if the submesh is ready to be used and all its information available.
  40269. * Child classes can use it to update shaders
  40270. * @param mesh defines the mesh to check
  40271. * @param subMesh defines which submesh to check
  40272. * @param useInstances specifies that instances should be used
  40273. * @returns a boolean indicating that the submesh is ready or not
  40274. */
  40275. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40276. /**
  40277. * Builds the material UBO layouts.
  40278. * Used internally during the effect preparation.
  40279. */
  40280. buildUniformLayout(): void;
  40281. /**
  40282. * Unbinds the material from the mesh
  40283. */
  40284. unbind(): void;
  40285. /**
  40286. * Binds the submesh to this material by preparing the effect and shader to draw
  40287. * @param world defines the world transformation matrix
  40288. * @param mesh defines the mesh containing the submesh
  40289. * @param subMesh defines the submesh to bind the material to
  40290. */
  40291. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40292. /**
  40293. * Get the list of animatables in the material.
  40294. * @returns the list of animatables object used in the material
  40295. */
  40296. getAnimatables(): IAnimatable[];
  40297. /**
  40298. * Gets the active textures from the material
  40299. * @returns an array of textures
  40300. */
  40301. getActiveTextures(): BaseTexture[];
  40302. /**
  40303. * Specifies if the material uses a texture
  40304. * @param texture defines the texture to check against the material
  40305. * @returns a boolean specifying if the material uses the texture
  40306. */
  40307. hasTexture(texture: BaseTexture): boolean;
  40308. /**
  40309. * Disposes the material
  40310. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40311. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40312. */
  40313. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40314. /**
  40315. * Makes a duplicate of the material, and gives it a new name
  40316. * @param name defines the new name for the duplicated material
  40317. * @returns the cloned material
  40318. */
  40319. clone(name: string): StandardMaterial;
  40320. /**
  40321. * Serializes this material in a JSON representation
  40322. * @returns the serialized material object
  40323. */
  40324. serialize(): any;
  40325. /**
  40326. * Creates a standard material from parsed material data
  40327. * @param source defines the JSON representation of the material
  40328. * @param scene defines the hosting scene
  40329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40330. * @returns a new standard material
  40331. */
  40332. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40333. /**
  40334. * Are diffuse textures enabled in the application.
  40335. */
  40336. static DiffuseTextureEnabled: boolean;
  40337. /**
  40338. * Are ambient textures enabled in the application.
  40339. */
  40340. static AmbientTextureEnabled: boolean;
  40341. /**
  40342. * Are opacity textures enabled in the application.
  40343. */
  40344. static OpacityTextureEnabled: boolean;
  40345. /**
  40346. * Are reflection textures enabled in the application.
  40347. */
  40348. static ReflectionTextureEnabled: boolean;
  40349. /**
  40350. * Are emissive textures enabled in the application.
  40351. */
  40352. static EmissiveTextureEnabled: boolean;
  40353. /**
  40354. * Are specular textures enabled in the application.
  40355. */
  40356. static SpecularTextureEnabled: boolean;
  40357. /**
  40358. * Are bump textures enabled in the application.
  40359. */
  40360. static BumpTextureEnabled: boolean;
  40361. /**
  40362. * Are lightmap textures enabled in the application.
  40363. */
  40364. static LightmapTextureEnabled: boolean;
  40365. /**
  40366. * Are refraction textures enabled in the application.
  40367. */
  40368. static RefractionTextureEnabled: boolean;
  40369. /**
  40370. * Are color grading textures enabled in the application.
  40371. */
  40372. static ColorGradingTextureEnabled: boolean;
  40373. /**
  40374. * Are fresnels enabled in the application.
  40375. */
  40376. static FresnelEnabled: boolean;
  40377. }
  40378. }
  40379. declare module BABYLON {
  40380. /**
  40381. * A class extending Texture allowing drawing on a texture
  40382. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40383. */
  40384. export class DynamicTexture extends Texture {
  40385. private _generateMipMaps;
  40386. private _canvas;
  40387. private _context;
  40388. private _engine;
  40389. /**
  40390. * Creates a DynamicTexture
  40391. * @param name defines the name of the texture
  40392. * @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
  40393. * @param scene defines the scene where you want the texture
  40394. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40395. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40396. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40397. */
  40398. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40399. /**
  40400. * Get the current class name of the texture useful for serialization or dynamic coding.
  40401. * @returns "DynamicTexture"
  40402. */
  40403. getClassName(): string;
  40404. /**
  40405. * Gets the current state of canRescale
  40406. */
  40407. readonly canRescale: boolean;
  40408. private _recreate;
  40409. /**
  40410. * Scales the texture
  40411. * @param ratio the scale factor to apply to both width and height
  40412. */
  40413. scale(ratio: number): void;
  40414. /**
  40415. * Resizes the texture
  40416. * @param width the new width
  40417. * @param height the new height
  40418. */
  40419. scaleTo(width: number, height: number): void;
  40420. /**
  40421. * Gets the context of the canvas used by the texture
  40422. * @returns the canvas context of the dynamic texture
  40423. */
  40424. getContext(): CanvasRenderingContext2D;
  40425. /**
  40426. * Clears the texture
  40427. */
  40428. clear(): void;
  40429. /**
  40430. * Updates the texture
  40431. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40432. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40433. */
  40434. update(invertY?: boolean, premulAlpha?: boolean): void;
  40435. /**
  40436. * Draws text onto the texture
  40437. * @param text defines the text to be drawn
  40438. * @param x defines the placement of the text from the left
  40439. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40440. * @param font defines the font to be used with font-style, font-size, font-name
  40441. * @param color defines the color used for the text
  40442. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40443. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40444. * @param update defines whether texture is immediately update (default is true)
  40445. */
  40446. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40447. /**
  40448. * Clones the texture
  40449. * @returns the clone of the texture.
  40450. */
  40451. clone(): DynamicTexture;
  40452. /**
  40453. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40454. * @returns a serialized dynamic texture object
  40455. */
  40456. serialize(): any;
  40457. /** @hidden */
  40458. _rebuild(): void;
  40459. }
  40460. }
  40461. declare module BABYLON {
  40462. /** @hidden */
  40463. export var imageProcessingPixelShader: {
  40464. name: string;
  40465. shader: string;
  40466. };
  40467. }
  40468. declare module BABYLON {
  40469. /**
  40470. * ImageProcessingPostProcess
  40471. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40472. */
  40473. export class ImageProcessingPostProcess extends PostProcess {
  40474. /**
  40475. * Default configuration related to image processing available in the PBR Material.
  40476. */
  40477. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40478. /**
  40479. * Gets the image processing configuration used either in this material.
  40480. */
  40481. /**
  40482. * Sets the Default image processing configuration used either in the this material.
  40483. *
  40484. * If sets to null, the scene one is in use.
  40485. */
  40486. imageProcessingConfiguration: ImageProcessingConfiguration;
  40487. /**
  40488. * Keep track of the image processing observer to allow dispose and replace.
  40489. */
  40490. private _imageProcessingObserver;
  40491. /**
  40492. * Attaches a new image processing configuration to the PBR Material.
  40493. * @param configuration
  40494. */
  40495. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40496. /**
  40497. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40498. */
  40499. /**
  40500. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40501. */
  40502. colorCurves: Nullable<ColorCurves>;
  40503. /**
  40504. * Gets wether the color curves effect is enabled.
  40505. */
  40506. /**
  40507. * Sets wether the color curves effect is enabled.
  40508. */
  40509. colorCurvesEnabled: boolean;
  40510. /**
  40511. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40512. */
  40513. /**
  40514. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40515. */
  40516. colorGradingTexture: Nullable<BaseTexture>;
  40517. /**
  40518. * Gets wether the color grading effect is enabled.
  40519. */
  40520. /**
  40521. * Gets wether the color grading effect is enabled.
  40522. */
  40523. colorGradingEnabled: boolean;
  40524. /**
  40525. * Gets exposure used in the effect.
  40526. */
  40527. /**
  40528. * Sets exposure used in the effect.
  40529. */
  40530. exposure: number;
  40531. /**
  40532. * Gets wether tonemapping is enabled or not.
  40533. */
  40534. /**
  40535. * Sets wether tonemapping is enabled or not
  40536. */
  40537. toneMappingEnabled: boolean;
  40538. /**
  40539. * Gets the type of tone mapping effect.
  40540. */
  40541. /**
  40542. * Sets the type of tone mapping effect.
  40543. */
  40544. toneMappingType: number;
  40545. /**
  40546. * Gets contrast used in the effect.
  40547. */
  40548. /**
  40549. * Sets contrast used in the effect.
  40550. */
  40551. contrast: number;
  40552. /**
  40553. * Gets Vignette stretch size.
  40554. */
  40555. /**
  40556. * Sets Vignette stretch size.
  40557. */
  40558. vignetteStretch: number;
  40559. /**
  40560. * Gets Vignette centre X Offset.
  40561. */
  40562. /**
  40563. * Sets Vignette centre X Offset.
  40564. */
  40565. vignetteCentreX: number;
  40566. /**
  40567. * Gets Vignette centre Y Offset.
  40568. */
  40569. /**
  40570. * Sets Vignette centre Y Offset.
  40571. */
  40572. vignetteCentreY: number;
  40573. /**
  40574. * Gets Vignette weight or intensity of the vignette effect.
  40575. */
  40576. /**
  40577. * Sets Vignette weight or intensity of the vignette effect.
  40578. */
  40579. vignetteWeight: number;
  40580. /**
  40581. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40582. * if vignetteEnabled is set to true.
  40583. */
  40584. /**
  40585. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40586. * if vignetteEnabled is set to true.
  40587. */
  40588. vignetteColor: Color4;
  40589. /**
  40590. * Gets Camera field of view used by the Vignette effect.
  40591. */
  40592. /**
  40593. * Sets Camera field of view used by the Vignette effect.
  40594. */
  40595. vignetteCameraFov: number;
  40596. /**
  40597. * Gets the vignette blend mode allowing different kind of effect.
  40598. */
  40599. /**
  40600. * Sets the vignette blend mode allowing different kind of effect.
  40601. */
  40602. vignetteBlendMode: number;
  40603. /**
  40604. * Gets wether the vignette effect is enabled.
  40605. */
  40606. /**
  40607. * Sets wether the vignette effect is enabled.
  40608. */
  40609. vignetteEnabled: boolean;
  40610. private _fromLinearSpace;
  40611. /**
  40612. * Gets wether the input of the processing is in Gamma or Linear Space.
  40613. */
  40614. /**
  40615. * Sets wether the input of the processing is in Gamma or Linear Space.
  40616. */
  40617. fromLinearSpace: boolean;
  40618. /**
  40619. * Defines cache preventing GC.
  40620. */
  40621. private _defines;
  40622. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40623. /**
  40624. * "ImageProcessingPostProcess"
  40625. * @returns "ImageProcessingPostProcess"
  40626. */
  40627. getClassName(): string;
  40628. protected _updateParameters(): void;
  40629. dispose(camera?: Camera): void;
  40630. }
  40631. }
  40632. declare module BABYLON {
  40633. /**
  40634. * Class containing static functions to help procedurally build meshes
  40635. */
  40636. export class GroundBuilder {
  40637. /**
  40638. * Creates a ground mesh
  40639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40642. * @param name defines the name of the mesh
  40643. * @param options defines the options used to create the mesh
  40644. * @param scene defines the hosting scene
  40645. * @returns the ground mesh
  40646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40647. */
  40648. static CreateGround(name: string, options: {
  40649. width?: number;
  40650. height?: number;
  40651. subdivisions?: number;
  40652. subdivisionsX?: number;
  40653. subdivisionsY?: number;
  40654. updatable?: boolean;
  40655. }, scene: any): Mesh;
  40656. /**
  40657. * Creates a tiled ground mesh
  40658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40660. * * 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
  40661. * * 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
  40662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40663. * @param name defines the name of the mesh
  40664. * @param options defines the options used to create the mesh
  40665. * @param scene defines the hosting scene
  40666. * @returns the tiled ground mesh
  40667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40668. */
  40669. static CreateTiledGround(name: string, options: {
  40670. xmin: number;
  40671. zmin: number;
  40672. xmax: number;
  40673. zmax: number;
  40674. subdivisions?: {
  40675. w: number;
  40676. h: number;
  40677. };
  40678. precision?: {
  40679. w: number;
  40680. h: number;
  40681. };
  40682. updatable?: boolean;
  40683. }, scene?: Nullable<Scene>): Mesh;
  40684. /**
  40685. * Creates a ground mesh from a height map
  40686. * * The parameter `url` sets the URL of the height map image resource.
  40687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40691. * * 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.
  40692. * * 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).
  40693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40695. * @param name defines the name of the mesh
  40696. * @param url defines the url to the height map
  40697. * @param options defines the options used to create the mesh
  40698. * @param scene defines the hosting scene
  40699. * @returns the ground mesh
  40700. * @see https://doc.babylonjs.com/babylon101/height_map
  40701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40702. */
  40703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40704. width?: number;
  40705. height?: number;
  40706. subdivisions?: number;
  40707. minHeight?: number;
  40708. maxHeight?: number;
  40709. colorFilter?: Color3;
  40710. alphaFilter?: number;
  40711. updatable?: boolean;
  40712. onReady?: (mesh: GroundMesh) => void;
  40713. }, scene?: Nullable<Scene>): GroundMesh;
  40714. }
  40715. }
  40716. declare module BABYLON {
  40717. /**
  40718. * Class containing static functions to help procedurally build meshes
  40719. */
  40720. export class TorusBuilder {
  40721. /**
  40722. * Creates a torus mesh
  40723. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40724. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40725. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40727. * * 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
  40728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40729. * @param name defines the name of the mesh
  40730. * @param options defines the options used to create the mesh
  40731. * @param scene defines the hosting scene
  40732. * @returns the torus mesh
  40733. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40734. */
  40735. static CreateTorus(name: string, options: {
  40736. diameter?: number;
  40737. thickness?: number;
  40738. tessellation?: number;
  40739. updatable?: boolean;
  40740. sideOrientation?: number;
  40741. frontUVs?: Vector4;
  40742. backUVs?: Vector4;
  40743. }, scene: any): Mesh;
  40744. }
  40745. }
  40746. declare module BABYLON {
  40747. /**
  40748. * Class containing static functions to help procedurally build meshes
  40749. */
  40750. export class CylinderBuilder {
  40751. /**
  40752. * Creates a cylinder or a cone mesh
  40753. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40754. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40755. * * 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.
  40756. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40757. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40758. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40759. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40760. * * 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).
  40761. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40762. * * 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).
  40763. * * 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
  40764. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40765. * * 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
  40766. * * 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.
  40767. * * If `enclose` is false, a ring surface is one element.
  40768. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40769. * * 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
  40770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40771. * * 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
  40772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40773. * @param name defines the name of the mesh
  40774. * @param options defines the options used to create the mesh
  40775. * @param scene defines the hosting scene
  40776. * @returns the cylinder mesh
  40777. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40778. */
  40779. static CreateCylinder(name: string, options: {
  40780. height?: number;
  40781. diameterTop?: number;
  40782. diameterBottom?: number;
  40783. diameter?: number;
  40784. tessellation?: number;
  40785. subdivisions?: number;
  40786. arc?: number;
  40787. faceColors?: Color4[];
  40788. faceUV?: Vector4[];
  40789. updatable?: boolean;
  40790. hasRings?: boolean;
  40791. enclose?: boolean;
  40792. cap?: number;
  40793. sideOrientation?: number;
  40794. frontUVs?: Vector4;
  40795. backUVs?: Vector4;
  40796. }, scene: any): Mesh;
  40797. }
  40798. }
  40799. declare module BABYLON {
  40800. /**
  40801. * Options to modify the vr teleportation behavior.
  40802. */
  40803. export interface VRTeleportationOptions {
  40804. /**
  40805. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40806. */
  40807. floorMeshName?: string;
  40808. /**
  40809. * A list of meshes to be used as the teleportation floor. (default: empty)
  40810. */
  40811. floorMeshes?: Mesh[];
  40812. }
  40813. /**
  40814. * Options to modify the vr experience helper's behavior.
  40815. */
  40816. export interface VRExperienceHelperOptions extends WebVROptions {
  40817. /**
  40818. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40819. */
  40820. createDeviceOrientationCamera?: boolean;
  40821. /**
  40822. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40823. */
  40824. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40825. /**
  40826. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40827. */
  40828. laserToggle?: boolean;
  40829. /**
  40830. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40831. */
  40832. floorMeshes?: Mesh[];
  40833. /**
  40834. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40835. */
  40836. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40837. }
  40838. /**
  40839. * Event containing information after VR has been entered
  40840. */
  40841. export class OnAfterEnteringVRObservableEvent {
  40842. /**
  40843. * If entering vr was successful
  40844. */
  40845. success: boolean;
  40846. }
  40847. /**
  40848. * Helps to quickly add VR support to an existing scene.
  40849. * See http://doc.babylonjs.com/how_to/webvr_helper
  40850. */
  40851. export class VRExperienceHelper {
  40852. /** Options to modify the vr experience helper's behavior. */
  40853. webVROptions: VRExperienceHelperOptions;
  40854. private _scene;
  40855. private _position;
  40856. private _btnVR;
  40857. private _btnVRDisplayed;
  40858. private _webVRsupported;
  40859. private _webVRready;
  40860. private _webVRrequesting;
  40861. private _webVRpresenting;
  40862. private _hasEnteredVR;
  40863. private _fullscreenVRpresenting;
  40864. private _canvas;
  40865. private _webVRCamera;
  40866. private _vrDeviceOrientationCamera;
  40867. private _deviceOrientationCamera;
  40868. private _existingCamera;
  40869. private _onKeyDown;
  40870. private _onVrDisplayPresentChange;
  40871. private _onVRDisplayChanged;
  40872. private _onVRRequestPresentStart;
  40873. private _onVRRequestPresentComplete;
  40874. /**
  40875. * 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)
  40876. */
  40877. enableGazeEvenWhenNoPointerLock: boolean;
  40878. /**
  40879. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40880. */
  40881. exitVROnDoubleTap: boolean;
  40882. /**
  40883. * Observable raised right before entering VR.
  40884. */
  40885. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40886. /**
  40887. * Observable raised when entering VR has completed.
  40888. */
  40889. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40890. /**
  40891. * Observable raised when exiting VR.
  40892. */
  40893. onExitingVRObservable: Observable<VRExperienceHelper>;
  40894. /**
  40895. * Observable raised when controller mesh is loaded.
  40896. */
  40897. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40898. /** Return this.onEnteringVRObservable
  40899. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40900. */
  40901. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40902. /** Return this.onExitingVRObservable
  40903. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40904. */
  40905. readonly onExitingVR: Observable<VRExperienceHelper>;
  40906. /** Return this.onControllerMeshLoadedObservable
  40907. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40908. */
  40909. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40910. private _rayLength;
  40911. private _useCustomVRButton;
  40912. private _teleportationRequested;
  40913. private _teleportActive;
  40914. private _floorMeshName;
  40915. private _floorMeshesCollection;
  40916. private _rotationAllowed;
  40917. private _teleportBackwardsVector;
  40918. private _teleportationTarget;
  40919. private _isDefaultTeleportationTarget;
  40920. private _postProcessMove;
  40921. private _teleportationFillColor;
  40922. private _teleportationBorderColor;
  40923. private _rotationAngle;
  40924. private _haloCenter;
  40925. private _cameraGazer;
  40926. private _padSensibilityUp;
  40927. private _padSensibilityDown;
  40928. private _leftController;
  40929. private _rightController;
  40930. /**
  40931. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40932. */
  40933. onNewMeshSelected: Observable<AbstractMesh>;
  40934. /**
  40935. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40936. * This observable will provide the mesh and the controller used to select the mesh
  40937. */
  40938. onMeshSelectedWithController: Observable<{
  40939. mesh: AbstractMesh;
  40940. controller: WebVRController;
  40941. }>;
  40942. /**
  40943. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40944. */
  40945. onNewMeshPicked: Observable<PickingInfo>;
  40946. private _circleEase;
  40947. /**
  40948. * Observable raised before camera teleportation
  40949. */
  40950. onBeforeCameraTeleport: Observable<Vector3>;
  40951. /**
  40952. * Observable raised after camera teleportation
  40953. */
  40954. onAfterCameraTeleport: Observable<Vector3>;
  40955. /**
  40956. * Observable raised when current selected mesh gets unselected
  40957. */
  40958. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40959. private _raySelectionPredicate;
  40960. /**
  40961. * To be optionaly changed by user to define custom ray selection
  40962. */
  40963. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40964. /**
  40965. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40966. */
  40967. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40968. /**
  40969. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40970. */
  40971. teleportationEnabled: boolean;
  40972. private _defaultHeight;
  40973. private _teleportationInitialized;
  40974. private _interactionsEnabled;
  40975. private _interactionsRequested;
  40976. private _displayGaze;
  40977. private _displayLaserPointer;
  40978. /**
  40979. * The mesh used to display where the user is going to teleport.
  40980. */
  40981. /**
  40982. * Sets the mesh to be used to display where the user is going to teleport.
  40983. */
  40984. teleportationTarget: Mesh;
  40985. /**
  40986. * 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
  40987. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40988. * See http://doc.babylonjs.com/resources/baking_transformations
  40989. */
  40990. gazeTrackerMesh: Mesh;
  40991. /**
  40992. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40993. */
  40994. updateGazeTrackerScale: boolean;
  40995. /**
  40996. * If the gaze trackers color should be updated when selecting meshes
  40997. */
  40998. updateGazeTrackerColor: boolean;
  40999. /**
  41000. * The gaze tracking mesh corresponding to the left controller
  41001. */
  41002. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41003. /**
  41004. * The gaze tracking mesh corresponding to the right controller
  41005. */
  41006. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41007. /**
  41008. * If the ray of the gaze should be displayed.
  41009. */
  41010. /**
  41011. * Sets if the ray of the gaze should be displayed.
  41012. */
  41013. displayGaze: boolean;
  41014. /**
  41015. * If the ray of the LaserPointer should be displayed.
  41016. */
  41017. /**
  41018. * Sets if the ray of the LaserPointer should be displayed.
  41019. */
  41020. displayLaserPointer: boolean;
  41021. /**
  41022. * The deviceOrientationCamera used as the camera when not in VR.
  41023. */
  41024. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41025. /**
  41026. * Based on the current WebVR support, returns the current VR camera used.
  41027. */
  41028. readonly currentVRCamera: Nullable<Camera>;
  41029. /**
  41030. * The webVRCamera which is used when in VR.
  41031. */
  41032. readonly webVRCamera: WebVRFreeCamera;
  41033. /**
  41034. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41035. */
  41036. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41037. /**
  41038. * The html button that is used to trigger entering into VR.
  41039. */
  41040. readonly vrButton: Nullable<HTMLButtonElement>;
  41041. private readonly _teleportationRequestInitiated;
  41042. /**
  41043. * Defines wether or not Pointer lock should be requested when switching to
  41044. * full screen.
  41045. */
  41046. requestPointerLockOnFullScreen: boolean;
  41047. /**
  41048. * Instantiates a VRExperienceHelper.
  41049. * Helps to quickly add VR support to an existing scene.
  41050. * @param scene The scene the VRExperienceHelper belongs to.
  41051. * @param webVROptions Options to modify the vr experience helper's behavior.
  41052. */
  41053. constructor(scene: Scene,
  41054. /** Options to modify the vr experience helper's behavior. */
  41055. webVROptions?: VRExperienceHelperOptions);
  41056. private _onDefaultMeshLoaded;
  41057. private _onResize;
  41058. private _onFullscreenChange;
  41059. /**
  41060. * Gets a value indicating if we are currently in VR mode.
  41061. */
  41062. readonly isInVRMode: boolean;
  41063. private onVrDisplayPresentChange;
  41064. private onVRDisplayChanged;
  41065. private moveButtonToBottomRight;
  41066. private displayVRButton;
  41067. private updateButtonVisibility;
  41068. private _cachedAngularSensibility;
  41069. /**
  41070. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41071. * Otherwise, will use the fullscreen API.
  41072. */
  41073. enterVR(): void;
  41074. /**
  41075. * Attempt to exit VR, or fullscreen.
  41076. */
  41077. exitVR(): void;
  41078. /**
  41079. * The position of the vr experience helper.
  41080. */
  41081. /**
  41082. * Sets the position of the vr experience helper.
  41083. */
  41084. position: Vector3;
  41085. /**
  41086. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41087. */
  41088. enableInteractions(): void;
  41089. private readonly _noControllerIsActive;
  41090. private beforeRender;
  41091. private _isTeleportationFloor;
  41092. /**
  41093. * Adds a floor mesh to be used for teleportation.
  41094. * @param floorMesh the mesh to be used for teleportation.
  41095. */
  41096. addFloorMesh(floorMesh: Mesh): void;
  41097. /**
  41098. * Removes a floor mesh from being used for teleportation.
  41099. * @param floorMesh the mesh to be removed.
  41100. */
  41101. removeFloorMesh(floorMesh: Mesh): void;
  41102. /**
  41103. * Enables interactions and teleportation using the VR controllers and gaze.
  41104. * @param vrTeleportationOptions options to modify teleportation behavior.
  41105. */
  41106. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41107. private _onNewGamepadConnected;
  41108. private _tryEnableInteractionOnController;
  41109. private _onNewGamepadDisconnected;
  41110. private _enableInteractionOnController;
  41111. private _checkTeleportWithRay;
  41112. private _checkRotate;
  41113. private _checkTeleportBackwards;
  41114. private _enableTeleportationOnController;
  41115. private _createTeleportationCircles;
  41116. private _displayTeleportationTarget;
  41117. private _hideTeleportationTarget;
  41118. private _rotateCamera;
  41119. private _moveTeleportationSelectorTo;
  41120. private _workingVector;
  41121. private _workingQuaternion;
  41122. private _workingMatrix;
  41123. /**
  41124. * Teleports the users feet to the desired location
  41125. * @param location The location where the user's feet should be placed
  41126. */
  41127. teleportCamera(location: Vector3): void;
  41128. private _convertNormalToDirectionOfRay;
  41129. private _castRayAndSelectObject;
  41130. private _notifySelectedMeshUnselected;
  41131. /**
  41132. * Sets the color of the laser ray from the vr controllers.
  41133. * @param color new color for the ray.
  41134. */
  41135. changeLaserColor(color: Color3): void;
  41136. /**
  41137. * Sets the color of the ray from the vr headsets gaze.
  41138. * @param color new color for the ray.
  41139. */
  41140. changeGazeColor(color: Color3): void;
  41141. /**
  41142. * Exits VR and disposes of the vr experience helper
  41143. */
  41144. dispose(): void;
  41145. /**
  41146. * Gets the name of the VRExperienceHelper class
  41147. * @returns "VRExperienceHelper"
  41148. */
  41149. getClassName(): string;
  41150. }
  41151. }
  41152. declare module BABYLON {
  41153. /**
  41154. * Manages an XRSession to work with Babylon's engine
  41155. * @see https://doc.babylonjs.com/how_to/webxr
  41156. */
  41157. export class WebXRSessionManager implements IDisposable {
  41158. private scene;
  41159. /**
  41160. * Fires every time a new xrFrame arrives which can be used to update the camera
  41161. */
  41162. onXRFrameObservable: Observable<any>;
  41163. /**
  41164. * Fires when the xr session is ended either by the device or manually done
  41165. */
  41166. onXRSessionEnded: Observable<any>;
  41167. /**
  41168. * Underlying xr session
  41169. */
  41170. session: XRSession;
  41171. /**
  41172. * Type of reference space used when creating the session
  41173. */
  41174. referenceSpace: XRReferenceSpace;
  41175. /** @hidden */
  41176. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41177. /**
  41178. * Current XR frame
  41179. */
  41180. currentFrame: Nullable<XRFrame>;
  41181. private _xrNavigator;
  41182. private baseLayer;
  41183. /**
  41184. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41185. * @param scene The scene which the session should be created for
  41186. */
  41187. constructor(scene: Scene);
  41188. /**
  41189. * Initializes the manager
  41190. * After initialization enterXR can be called to start an XR session
  41191. * @returns Promise which resolves after it is initialized
  41192. */
  41193. initializeAsync(): Promise<void>;
  41194. /**
  41195. * Initializes an xr session
  41196. * @param xrSessionMode mode to initialize
  41197. * @returns a promise which will resolve once the session has been initialized
  41198. */
  41199. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41200. /**
  41201. * Sets the reference space on the xr session
  41202. * @param referenceSpace space to set
  41203. * @returns a promise that will resolve once the reference space has been set
  41204. */
  41205. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41206. /**
  41207. * Updates the render state of the session
  41208. * @param state state to set
  41209. * @returns a promise that resolves once the render state has been updated
  41210. */
  41211. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41212. /**
  41213. * Starts rendering to the xr layer
  41214. * @returns a promise that will resolve once rendering has started
  41215. */
  41216. startRenderingToXRAsync(): Promise<void>;
  41217. /**
  41218. * Stops the xrSession and restores the renderloop
  41219. * @returns Promise which resolves after it exits XR
  41220. */
  41221. exitXRAsync(): Promise<unknown>;
  41222. /**
  41223. * Checks if a session would be supported for the creation options specified
  41224. * @param sessionMode session mode to check if supported eg. immersive-vr
  41225. * @returns true if supported
  41226. */
  41227. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41228. /**
  41229. * @hidden
  41230. * Converts the render layer of xrSession to a render target
  41231. * @param session session to create render target for
  41232. * @param scene scene the new render target should be created for
  41233. */
  41234. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41235. /**
  41236. * Disposes of the session manager
  41237. */
  41238. dispose(): void;
  41239. }
  41240. }
  41241. declare module BABYLON {
  41242. /**
  41243. * WebXR Camera which holds the views for the xrSession
  41244. * @see https://doc.babylonjs.com/how_to/webxr
  41245. */
  41246. export class WebXRCamera extends FreeCamera {
  41247. private static _TmpMatrix;
  41248. /**
  41249. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41250. * @param name the name of the camera
  41251. * @param scene the scene to add the camera to
  41252. */
  41253. constructor(name: string, scene: Scene);
  41254. private _updateNumberOfRigCameras;
  41255. /** @hidden */
  41256. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41257. /**
  41258. * Updates the cameras position from the current pose information of the XR session
  41259. * @param xrSessionManager the session containing pose information
  41260. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41261. */
  41262. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41263. }
  41264. }
  41265. declare module BABYLON {
  41266. /**
  41267. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41268. */
  41269. export class WebXRManagedOutputCanvas implements IDisposable {
  41270. private helper;
  41271. private _canvas;
  41272. /**
  41273. * xrpresent context of the canvas which can be used to display/mirror xr content
  41274. */
  41275. canvasContext: WebGLRenderingContext;
  41276. /**
  41277. * xr layer for the canvas
  41278. */
  41279. xrLayer: Nullable<XRWebGLLayer>;
  41280. /**
  41281. * Initializes the xr layer for the session
  41282. * @param xrSession xr session
  41283. * @returns a promise that will resolve once the XR Layer has been created
  41284. */
  41285. initializeXRLayerAsync(xrSession: any): any;
  41286. /**
  41287. * Initializes the canvas to be added/removed upon entering/exiting xr
  41288. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41289. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41290. */
  41291. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41292. /**
  41293. * Disposes of the object
  41294. */
  41295. dispose(): void;
  41296. private _setManagedOutputCanvas;
  41297. private _addCanvas;
  41298. private _removeCanvas;
  41299. }
  41300. }
  41301. declare module BABYLON {
  41302. /**
  41303. * States of the webXR experience
  41304. */
  41305. export enum WebXRState {
  41306. /**
  41307. * Transitioning to being in XR mode
  41308. */
  41309. ENTERING_XR = 0,
  41310. /**
  41311. * Transitioning to non XR mode
  41312. */
  41313. EXITING_XR = 1,
  41314. /**
  41315. * In XR mode and presenting
  41316. */
  41317. IN_XR = 2,
  41318. /**
  41319. * Not entered XR mode
  41320. */
  41321. NOT_IN_XR = 3
  41322. }
  41323. /**
  41324. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41325. * @see https://doc.babylonjs.com/how_to/webxr
  41326. */
  41327. export class WebXRExperienceHelper implements IDisposable {
  41328. private scene;
  41329. /**
  41330. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41331. */
  41332. container: AbstractMesh;
  41333. /**
  41334. * Camera used to render xr content
  41335. */
  41336. camera: WebXRCamera;
  41337. /**
  41338. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41339. */
  41340. state: WebXRState;
  41341. private _setState;
  41342. private static _TmpVector;
  41343. /**
  41344. * Fires when the state of the experience helper has changed
  41345. */
  41346. onStateChangedObservable: Observable<WebXRState>;
  41347. /** Session manager used to keep track of xr session */
  41348. sessionManager: WebXRSessionManager;
  41349. private _nonVRCamera;
  41350. private _originalSceneAutoClear;
  41351. private _supported;
  41352. /**
  41353. * Creates the experience helper
  41354. * @param scene the scene to attach the experience helper to
  41355. * @returns a promise for the experience helper
  41356. */
  41357. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41358. /**
  41359. * Creates a WebXRExperienceHelper
  41360. * @param scene The scene the helper should be created in
  41361. */
  41362. private constructor();
  41363. /**
  41364. * Exits XR mode and returns the scene to its original state
  41365. * @returns promise that resolves after xr mode has exited
  41366. */
  41367. exitXRAsync(): Promise<unknown>;
  41368. /**
  41369. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41370. * @param sessionCreationOptions options for the XR session
  41371. * @param referenceSpaceType frame of reference of the XR session
  41372. * @param outputCanvas the output canvas that will be used to enter XR mode
  41373. * @returns promise that resolves after xr mode has entered
  41374. */
  41375. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41376. /**
  41377. * Updates the global position of the camera by moving the camera's container
  41378. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41379. * @param position The desired global position of the camera
  41380. */
  41381. setPositionOfCameraUsingContainer(position: Vector3): void;
  41382. /**
  41383. * Rotates the xr camera by rotating the camera's container around the camera's position
  41384. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41385. * @param rotation the desired quaternion rotation to apply to the camera
  41386. */
  41387. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41388. /**
  41389. * Disposes of the experience helper
  41390. */
  41391. dispose(): void;
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. /**
  41396. * Button which can be used to enter a different mode of XR
  41397. */
  41398. export class WebXREnterExitUIButton {
  41399. /** button element */
  41400. element: HTMLElement;
  41401. /** XR initialization options for the button */
  41402. sessionMode: XRSessionMode;
  41403. /** Reference space type */
  41404. referenceSpaceType: XRReferenceSpaceType;
  41405. /**
  41406. * Creates a WebXREnterExitUIButton
  41407. * @param element button element
  41408. * @param sessionMode XR initialization session mode
  41409. * @param referenceSpaceType the type of reference space to be used
  41410. */
  41411. constructor(
  41412. /** button element */
  41413. element: HTMLElement,
  41414. /** XR initialization options for the button */
  41415. sessionMode: XRSessionMode,
  41416. /** Reference space type */
  41417. referenceSpaceType: XRReferenceSpaceType);
  41418. /**
  41419. * Overwritable function which can be used to update the button's visuals when the state changes
  41420. * @param activeButton the current active button in the UI
  41421. */
  41422. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41423. }
  41424. /**
  41425. * Options to create the webXR UI
  41426. */
  41427. export class WebXREnterExitUIOptions {
  41428. /**
  41429. * Context to enter xr with
  41430. */
  41431. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41432. /**
  41433. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41434. */
  41435. customButtons?: Array<WebXREnterExitUIButton>;
  41436. }
  41437. /**
  41438. * UI to allow the user to enter/exit XR mode
  41439. */
  41440. export class WebXREnterExitUI implements IDisposable {
  41441. private scene;
  41442. private _overlay;
  41443. private _buttons;
  41444. private _activeButton;
  41445. /**
  41446. * Fired every time the active button is changed.
  41447. *
  41448. * When xr is entered via a button that launches xr that button will be the callback parameter
  41449. *
  41450. * When exiting xr the callback parameter will be null)
  41451. */
  41452. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41453. /**
  41454. * Creates UI to allow the user to enter/exit XR mode
  41455. * @param scene the scene to add the ui to
  41456. * @param helper the xr experience helper to enter/exit xr with
  41457. * @param options options to configure the UI
  41458. * @returns the created ui
  41459. */
  41460. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41461. private constructor();
  41462. private _updateButtons;
  41463. /**
  41464. * Disposes of the object
  41465. */
  41466. dispose(): void;
  41467. }
  41468. }
  41469. declare module BABYLON {
  41470. /**
  41471. * Represents an XR input
  41472. */
  41473. export class WebXRController {
  41474. private scene;
  41475. /** The underlying input source for the controller */
  41476. inputSource: XRInputSource;
  41477. private parentContainer;
  41478. /**
  41479. * 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
  41480. */
  41481. grip?: AbstractMesh;
  41482. /**
  41483. * Pointer which can be used to select objects or attach a visible laser to
  41484. */
  41485. pointer: AbstractMesh;
  41486. /**
  41487. * Event that fires when the controller is removed/disposed
  41488. */
  41489. onDisposeObservable: Observable<{}>;
  41490. private _tmpMatrix;
  41491. private _tmpQuaternion;
  41492. private _tmpVector;
  41493. /**
  41494. * Creates the controller
  41495. * @see https://doc.babylonjs.com/how_to/webxr
  41496. * @param scene the scene which the controller should be associated to
  41497. * @param inputSource the underlying input source for the controller
  41498. * @param parentContainer parent that the controller meshes should be children of
  41499. */
  41500. constructor(scene: Scene,
  41501. /** The underlying input source for the controller */
  41502. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41503. /**
  41504. * Updates the controller pose based on the given XRFrame
  41505. * @param xrFrame xr frame to update the pose with
  41506. * @param referenceSpace reference space to use
  41507. */
  41508. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41509. /**
  41510. * Gets a world space ray coming from the controller
  41511. * @param result the resulting ray
  41512. */
  41513. getWorldPointerRayToRef(result: Ray): void;
  41514. /**
  41515. * Disposes of the object
  41516. */
  41517. dispose(): void;
  41518. }
  41519. }
  41520. declare module BABYLON {
  41521. /**
  41522. * XR input used to track XR inputs such as controllers/rays
  41523. */
  41524. export class WebXRInput implements IDisposable {
  41525. /**
  41526. * Base experience the input listens to
  41527. */
  41528. baseExperience: WebXRExperienceHelper;
  41529. /**
  41530. * XR controllers being tracked
  41531. */
  41532. controllers: Array<WebXRController>;
  41533. private _frameObserver;
  41534. private _stateObserver;
  41535. /**
  41536. * Event when a controller has been connected/added
  41537. */
  41538. onControllerAddedObservable: Observable<WebXRController>;
  41539. /**
  41540. * Event when a controller has been removed/disconnected
  41541. */
  41542. onControllerRemovedObservable: Observable<WebXRController>;
  41543. /**
  41544. * Initializes the WebXRInput
  41545. * @param baseExperience experience helper which the input should be created for
  41546. */
  41547. constructor(
  41548. /**
  41549. * Base experience the input listens to
  41550. */
  41551. baseExperience: WebXRExperienceHelper);
  41552. private _onInputSourcesChange;
  41553. private _addAndRemoveControllers;
  41554. /**
  41555. * Disposes of the object
  41556. */
  41557. dispose(): void;
  41558. }
  41559. }
  41560. declare module BABYLON {
  41561. /**
  41562. * Enables teleportation
  41563. */
  41564. export class WebXRControllerTeleportation {
  41565. private _teleportationFillColor;
  41566. private _teleportationBorderColor;
  41567. private _tmpRay;
  41568. private _tmpVector;
  41569. /**
  41570. * Creates a WebXRControllerTeleportation
  41571. * @param input input manager to add teleportation to
  41572. * @param floorMeshes floormeshes which can be teleported to
  41573. */
  41574. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41575. }
  41576. }
  41577. declare module BABYLON {
  41578. /**
  41579. * Handles pointer input automatically for the pointer of XR controllers
  41580. */
  41581. export class WebXRControllerPointerSelection {
  41582. private static _idCounter;
  41583. private _tmpRay;
  41584. /**
  41585. * Creates a WebXRControllerPointerSelection
  41586. * @param input input manager to setup pointer selection
  41587. */
  41588. constructor(input: WebXRInput);
  41589. private _convertNormalToDirectionOfRay;
  41590. private _updatePointerDistance;
  41591. }
  41592. }
  41593. declare module BABYLON {
  41594. /**
  41595. * Class used to represent data loading progression
  41596. */
  41597. export class SceneLoaderProgressEvent {
  41598. /** defines if data length to load can be evaluated */
  41599. readonly lengthComputable: boolean;
  41600. /** defines the loaded data length */
  41601. readonly loaded: number;
  41602. /** defines the data length to load */
  41603. readonly total: number;
  41604. /**
  41605. * Create a new progress event
  41606. * @param lengthComputable defines if data length to load can be evaluated
  41607. * @param loaded defines the loaded data length
  41608. * @param total defines the data length to load
  41609. */
  41610. constructor(
  41611. /** defines if data length to load can be evaluated */
  41612. lengthComputable: boolean,
  41613. /** defines the loaded data length */
  41614. loaded: number,
  41615. /** defines the data length to load */
  41616. total: number);
  41617. /**
  41618. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41619. * @param event defines the source event
  41620. * @returns a new SceneLoaderProgressEvent
  41621. */
  41622. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41623. }
  41624. /**
  41625. * Interface used by SceneLoader plugins to define supported file extensions
  41626. */
  41627. export interface ISceneLoaderPluginExtensions {
  41628. /**
  41629. * Defines the list of supported extensions
  41630. */
  41631. [extension: string]: {
  41632. isBinary: boolean;
  41633. };
  41634. }
  41635. /**
  41636. * Interface used by SceneLoader plugin factory
  41637. */
  41638. export interface ISceneLoaderPluginFactory {
  41639. /**
  41640. * Defines the name of the factory
  41641. */
  41642. name: string;
  41643. /**
  41644. * Function called to create a new plugin
  41645. * @return the new plugin
  41646. */
  41647. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41648. /**
  41649. * Boolean indicating if the plugin can direct load specific data
  41650. */
  41651. canDirectLoad?: (data: string) => boolean;
  41652. }
  41653. /**
  41654. * Interface used to define a SceneLoader plugin
  41655. */
  41656. export interface ISceneLoaderPlugin {
  41657. /**
  41658. * The friendly name of this plugin.
  41659. */
  41660. name: string;
  41661. /**
  41662. * The file extensions supported by this plugin.
  41663. */
  41664. extensions: string | ISceneLoaderPluginExtensions;
  41665. /**
  41666. * Import meshes into a scene.
  41667. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41668. * @param scene The scene to import into
  41669. * @param data The data to import
  41670. * @param rootUrl The root url for scene and resources
  41671. * @param meshes The meshes array to import into
  41672. * @param particleSystems The particle systems array to import into
  41673. * @param skeletons The skeletons array to import into
  41674. * @param onError The callback when import fails
  41675. * @returns True if successful or false otherwise
  41676. */
  41677. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41678. /**
  41679. * Load into a scene.
  41680. * @param scene The scene to load into
  41681. * @param data The data to import
  41682. * @param rootUrl The root url for scene and resources
  41683. * @param onError The callback when import fails
  41684. * @returns true if successful or false otherwise
  41685. */
  41686. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41687. /**
  41688. * The callback that returns true if the data can be directly loaded.
  41689. */
  41690. canDirectLoad?: (data: string) => boolean;
  41691. /**
  41692. * The callback that allows custom handling of the root url based on the response url.
  41693. */
  41694. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41695. /**
  41696. * Load into an asset container.
  41697. * @param scene The scene to load into
  41698. * @param data The data to import
  41699. * @param rootUrl The root url for scene and resources
  41700. * @param onError The callback when import fails
  41701. * @returns The loaded asset container
  41702. */
  41703. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41704. }
  41705. /**
  41706. * Interface used to define an async SceneLoader plugin
  41707. */
  41708. export interface ISceneLoaderPluginAsync {
  41709. /**
  41710. * The friendly name of this plugin.
  41711. */
  41712. name: string;
  41713. /**
  41714. * The file extensions supported by this plugin.
  41715. */
  41716. extensions: string | ISceneLoaderPluginExtensions;
  41717. /**
  41718. * Import meshes into a scene.
  41719. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41720. * @param scene The scene to import into
  41721. * @param data The data to import
  41722. * @param rootUrl The root url for scene and resources
  41723. * @param onProgress The callback when the load progresses
  41724. * @param fileName Defines the name of the file to load
  41725. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41726. */
  41727. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41728. meshes: AbstractMesh[];
  41729. particleSystems: IParticleSystem[];
  41730. skeletons: Skeleton[];
  41731. animationGroups: AnimationGroup[];
  41732. }>;
  41733. /**
  41734. * Load into a scene.
  41735. * @param scene The scene to load into
  41736. * @param data The data to import
  41737. * @param rootUrl The root url for scene and resources
  41738. * @param onProgress The callback when the load progresses
  41739. * @param fileName Defines the name of the file to load
  41740. * @returns Nothing
  41741. */
  41742. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41743. /**
  41744. * The callback that returns true if the data can be directly loaded.
  41745. */
  41746. canDirectLoad?: (data: string) => boolean;
  41747. /**
  41748. * The callback that allows custom handling of the root url based on the response url.
  41749. */
  41750. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41751. /**
  41752. * Load into an asset container.
  41753. * @param scene The scene to load into
  41754. * @param data The data to import
  41755. * @param rootUrl The root url for scene and resources
  41756. * @param onProgress The callback when the load progresses
  41757. * @param fileName Defines the name of the file to load
  41758. * @returns The loaded asset container
  41759. */
  41760. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41761. }
  41762. /**
  41763. * Class used to load scene from various file formats using registered plugins
  41764. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41765. */
  41766. export class SceneLoader {
  41767. /**
  41768. * No logging while loading
  41769. */
  41770. static readonly NO_LOGGING: number;
  41771. /**
  41772. * Minimal logging while loading
  41773. */
  41774. static readonly MINIMAL_LOGGING: number;
  41775. /**
  41776. * Summary logging while loading
  41777. */
  41778. static readonly SUMMARY_LOGGING: number;
  41779. /**
  41780. * Detailled logging while loading
  41781. */
  41782. static readonly DETAILED_LOGGING: number;
  41783. /**
  41784. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41785. */
  41786. static ForceFullSceneLoadingForIncremental: boolean;
  41787. /**
  41788. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41789. */
  41790. static ShowLoadingScreen: boolean;
  41791. /**
  41792. * Defines the current logging level (while loading the scene)
  41793. * @ignorenaming
  41794. */
  41795. static loggingLevel: number;
  41796. /**
  41797. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41798. */
  41799. static CleanBoneMatrixWeights: boolean;
  41800. /**
  41801. * Event raised when a plugin is used to load a scene
  41802. */
  41803. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41804. private static _registeredPlugins;
  41805. private static _getDefaultPlugin;
  41806. private static _getPluginForExtension;
  41807. private static _getPluginForDirectLoad;
  41808. private static _getPluginForFilename;
  41809. private static _getDirectLoad;
  41810. private static _loadData;
  41811. private static _getFileInfo;
  41812. /**
  41813. * Gets a plugin that can load the given extension
  41814. * @param extension defines the extension to load
  41815. * @returns a plugin or null if none works
  41816. */
  41817. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41818. /**
  41819. * Gets a boolean indicating that the given extension can be loaded
  41820. * @param extension defines the extension to load
  41821. * @returns true if the extension is supported
  41822. */
  41823. static IsPluginForExtensionAvailable(extension: string): boolean;
  41824. /**
  41825. * Adds a new plugin to the list of registered plugins
  41826. * @param plugin defines the plugin to add
  41827. */
  41828. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41829. /**
  41830. * Import meshes into a scene
  41831. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41832. * @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)
  41833. * @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)
  41834. * @param scene the instance of BABYLON.Scene to append to
  41835. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41836. * @param onProgress a callback with a progress event for each file being loaded
  41837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41838. * @param pluginExtension the extension used to determine the plugin
  41839. * @returns The loaded plugin
  41840. */
  41841. 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>;
  41842. /**
  41843. * Import meshes into a scene
  41844. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41845. * @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)
  41846. * @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)
  41847. * @param scene the instance of BABYLON.Scene to append to
  41848. * @param onProgress a callback with a progress event for each file being loaded
  41849. * @param pluginExtension the extension used to determine the plugin
  41850. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41851. */
  41852. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41853. meshes: AbstractMesh[];
  41854. particleSystems: IParticleSystem[];
  41855. skeletons: Skeleton[];
  41856. animationGroups: AnimationGroup[];
  41857. }>;
  41858. /**
  41859. * Load a scene
  41860. * @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)
  41861. * @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)
  41862. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41863. * @param onSuccess a callback with the scene when import succeeds
  41864. * @param onProgress a callback with a progress event for each file being loaded
  41865. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41866. * @param pluginExtension the extension used to determine the plugin
  41867. * @returns The loaded plugin
  41868. */
  41869. 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>;
  41870. /**
  41871. * Load a scene
  41872. * @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)
  41873. * @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)
  41874. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41875. * @param onProgress a callback with a progress event for each file being loaded
  41876. * @param pluginExtension the extension used to determine the plugin
  41877. * @returns The loaded scene
  41878. */
  41879. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41880. /**
  41881. * Append a scene
  41882. * @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)
  41883. * @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)
  41884. * @param scene is the instance of BABYLON.Scene to append to
  41885. * @param onSuccess a callback with the scene when import succeeds
  41886. * @param onProgress a callback with a progress event for each file being loaded
  41887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41888. * @param pluginExtension the extension used to determine the plugin
  41889. * @returns The loaded plugin
  41890. */
  41891. 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>;
  41892. /**
  41893. * Append a scene
  41894. * @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)
  41895. * @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)
  41896. * @param scene is the instance of BABYLON.Scene to append to
  41897. * @param onProgress a callback with a progress event for each file being loaded
  41898. * @param pluginExtension the extension used to determine the plugin
  41899. * @returns The given scene
  41900. */
  41901. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41902. /**
  41903. * Load a scene into an asset container
  41904. * @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)
  41905. * @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)
  41906. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41907. * @param onSuccess a callback with the scene when import succeeds
  41908. * @param onProgress a callback with a progress event for each file being loaded
  41909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41910. * @param pluginExtension the extension used to determine the plugin
  41911. * @returns The loaded plugin
  41912. */
  41913. 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>;
  41914. /**
  41915. * Load a scene into an asset container
  41916. * @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)
  41917. * @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)
  41918. * @param scene is the instance of Scene to append to
  41919. * @param onProgress a callback with a progress event for each file being loaded
  41920. * @param pluginExtension the extension used to determine the plugin
  41921. * @returns The loaded asset container
  41922. */
  41923. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * Generic Controller
  41929. */
  41930. export class GenericController extends WebVRController {
  41931. /**
  41932. * Base Url for the controller model.
  41933. */
  41934. static readonly MODEL_BASE_URL: string;
  41935. /**
  41936. * File name for the controller model.
  41937. */
  41938. static readonly MODEL_FILENAME: string;
  41939. /**
  41940. * Creates a new GenericController from a gamepad
  41941. * @param vrGamepad the gamepad that the controller should be created from
  41942. */
  41943. constructor(vrGamepad: any);
  41944. /**
  41945. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41946. * @param scene scene in which to add meshes
  41947. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41948. */
  41949. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41950. /**
  41951. * Called once for each button that changed state since the last frame
  41952. * @param buttonIdx Which button index changed
  41953. * @param state New state of the button
  41954. * @param changes Which properties on the state changed since last frame
  41955. */
  41956. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41957. }
  41958. }
  41959. declare module BABYLON {
  41960. /**
  41961. * Defines the WindowsMotionController object that the state of the windows motion controller
  41962. */
  41963. export class WindowsMotionController extends WebVRController {
  41964. /**
  41965. * The base url used to load the left and right controller models
  41966. */
  41967. static MODEL_BASE_URL: string;
  41968. /**
  41969. * The name of the left controller model file
  41970. */
  41971. static MODEL_LEFT_FILENAME: string;
  41972. /**
  41973. * The name of the right controller model file
  41974. */
  41975. static MODEL_RIGHT_FILENAME: string;
  41976. /**
  41977. * The controller name prefix for this controller type
  41978. */
  41979. static readonly GAMEPAD_ID_PREFIX: string;
  41980. /**
  41981. * The controller id pattern for this controller type
  41982. */
  41983. private static readonly GAMEPAD_ID_PATTERN;
  41984. private _loadedMeshInfo;
  41985. private readonly _mapping;
  41986. /**
  41987. * Fired when the trackpad on this controller is clicked
  41988. */
  41989. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41990. /**
  41991. * Fired when the trackpad on this controller is modified
  41992. */
  41993. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41994. /**
  41995. * The current x and y values of this controller's trackpad
  41996. */
  41997. trackpad: StickValues;
  41998. /**
  41999. * Creates a new WindowsMotionController from a gamepad
  42000. * @param vrGamepad the gamepad that the controller should be created from
  42001. */
  42002. constructor(vrGamepad: any);
  42003. /**
  42004. * Fired when the trigger on this controller is modified
  42005. */
  42006. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42007. /**
  42008. * Fired when the menu button on this controller is modified
  42009. */
  42010. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42011. /**
  42012. * Fired when the grip button on this controller is modified
  42013. */
  42014. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42015. /**
  42016. * Fired when the thumbstick button on this controller is modified
  42017. */
  42018. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42019. /**
  42020. * Fired when the touchpad button on this controller is modified
  42021. */
  42022. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42023. /**
  42024. * Fired when the touchpad values on this controller are modified
  42025. */
  42026. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42027. private _updateTrackpad;
  42028. /**
  42029. * Called once per frame by the engine.
  42030. */
  42031. update(): void;
  42032. /**
  42033. * Called once for each button that changed state since the last frame
  42034. * @param buttonIdx Which button index changed
  42035. * @param state New state of the button
  42036. * @param changes Which properties on the state changed since last frame
  42037. */
  42038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42039. /**
  42040. * Moves the buttons on the controller mesh based on their current state
  42041. * @param buttonName the name of the button to move
  42042. * @param buttonValue the value of the button which determines the buttons new position
  42043. */
  42044. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42045. /**
  42046. * Moves the axis on the controller mesh based on its current state
  42047. * @param axis the index of the axis
  42048. * @param axisValue the value of the axis which determines the meshes new position
  42049. * @hidden
  42050. */
  42051. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42052. /**
  42053. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42054. * @param scene scene in which to add meshes
  42055. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42056. */
  42057. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42058. /**
  42059. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42060. * can be transformed by button presses and axes values, based on this._mapping.
  42061. *
  42062. * @param scene scene in which the meshes exist
  42063. * @param meshes list of meshes that make up the controller model to process
  42064. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42065. */
  42066. private processModel;
  42067. private createMeshInfo;
  42068. /**
  42069. * Gets the ray of the controller in the direction the controller is pointing
  42070. * @param length the length the resulting ray should be
  42071. * @returns a ray in the direction the controller is pointing
  42072. */
  42073. getForwardRay(length?: number): Ray;
  42074. /**
  42075. * Disposes of the controller
  42076. */
  42077. dispose(): void;
  42078. }
  42079. }
  42080. declare module BABYLON {
  42081. /**
  42082. * Oculus Touch Controller
  42083. */
  42084. export class OculusTouchController extends WebVRController {
  42085. /**
  42086. * Base Url for the controller model.
  42087. */
  42088. static MODEL_BASE_URL: string;
  42089. /**
  42090. * File name for the left controller model.
  42091. */
  42092. static MODEL_LEFT_FILENAME: string;
  42093. /**
  42094. * File name for the right controller model.
  42095. */
  42096. static MODEL_RIGHT_FILENAME: string;
  42097. /**
  42098. * Base Url for the Quest controller model.
  42099. */
  42100. static QUEST_MODEL_BASE_URL: string;
  42101. /**
  42102. * @hidden
  42103. * If the controllers are running on a device that needs the updated Quest controller models
  42104. */
  42105. static _IsQuest: boolean;
  42106. /**
  42107. * Fired when the secondary trigger on this controller is modified
  42108. */
  42109. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42110. /**
  42111. * Fired when the thumb rest on this controller is modified
  42112. */
  42113. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42114. /**
  42115. * Creates a new OculusTouchController from a gamepad
  42116. * @param vrGamepad the gamepad that the controller should be created from
  42117. */
  42118. constructor(vrGamepad: any);
  42119. /**
  42120. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42121. * @param scene scene in which to add meshes
  42122. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42123. */
  42124. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42125. /**
  42126. * Fired when the A button on this controller is modified
  42127. */
  42128. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42129. /**
  42130. * Fired when the B button on this controller is modified
  42131. */
  42132. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42133. /**
  42134. * Fired when the X button on this controller is modified
  42135. */
  42136. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42137. /**
  42138. * Fired when the Y button on this controller is modified
  42139. */
  42140. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42141. /**
  42142. * Called once for each button that changed state since the last frame
  42143. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42144. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42145. * 2) secondary trigger (same)
  42146. * 3) A (right) X (left), touch, pressed = value
  42147. * 4) B / Y
  42148. * 5) thumb rest
  42149. * @param buttonIdx Which button index changed
  42150. * @param state New state of the button
  42151. * @param changes Which properties on the state changed since last frame
  42152. */
  42153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42154. }
  42155. }
  42156. declare module BABYLON {
  42157. /**
  42158. * Vive Controller
  42159. */
  42160. export class ViveController extends WebVRController {
  42161. /**
  42162. * Base Url for the controller model.
  42163. */
  42164. static MODEL_BASE_URL: string;
  42165. /**
  42166. * File name for the controller model.
  42167. */
  42168. static MODEL_FILENAME: string;
  42169. /**
  42170. * Creates a new ViveController from a gamepad
  42171. * @param vrGamepad the gamepad that the controller should be created from
  42172. */
  42173. constructor(vrGamepad: any);
  42174. /**
  42175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42176. * @param scene scene in which to add meshes
  42177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42178. */
  42179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42180. /**
  42181. * Fired when the left button on this controller is modified
  42182. */
  42183. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42184. /**
  42185. * Fired when the right button on this controller is modified
  42186. */
  42187. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42188. /**
  42189. * Fired when the menu button on this controller is modified
  42190. */
  42191. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42192. /**
  42193. * Called once for each button that changed state since the last frame
  42194. * Vive mapping:
  42195. * 0: touchpad
  42196. * 1: trigger
  42197. * 2: left AND right buttons
  42198. * 3: menu button
  42199. * @param buttonIdx Which button index changed
  42200. * @param state New state of the button
  42201. * @param changes Which properties on the state changed since last frame
  42202. */
  42203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42204. }
  42205. }
  42206. declare module BABYLON {
  42207. /**
  42208. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42209. */
  42210. export class WebXRControllerModelLoader {
  42211. /**
  42212. * Creates the WebXRControllerModelLoader
  42213. * @param input xr input that creates the controllers
  42214. */
  42215. constructor(input: WebXRInput);
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Contains an array of blocks representing the octree
  42221. */
  42222. export interface IOctreeContainer<T> {
  42223. /**
  42224. * Blocks within the octree
  42225. */
  42226. blocks: Array<OctreeBlock<T>>;
  42227. }
  42228. /**
  42229. * Class used to store a cell in an octree
  42230. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42231. */
  42232. export class OctreeBlock<T> {
  42233. /**
  42234. * Gets the content of the current block
  42235. */
  42236. entries: T[];
  42237. /**
  42238. * Gets the list of block children
  42239. */
  42240. blocks: Array<OctreeBlock<T>>;
  42241. private _depth;
  42242. private _maxDepth;
  42243. private _capacity;
  42244. private _minPoint;
  42245. private _maxPoint;
  42246. private _boundingVectors;
  42247. private _creationFunc;
  42248. /**
  42249. * Creates a new block
  42250. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42251. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42252. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42253. * @param depth defines the current depth of this block in the octree
  42254. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42255. * @param creationFunc defines a callback to call when an element is added to the block
  42256. */
  42257. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42258. /**
  42259. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42260. */
  42261. readonly capacity: number;
  42262. /**
  42263. * Gets the minimum vector (in world space) of the block's bounding box
  42264. */
  42265. readonly minPoint: Vector3;
  42266. /**
  42267. * Gets the maximum vector (in world space) of the block's bounding box
  42268. */
  42269. readonly maxPoint: Vector3;
  42270. /**
  42271. * Add a new element to this block
  42272. * @param entry defines the element to add
  42273. */
  42274. addEntry(entry: T): void;
  42275. /**
  42276. * Remove an element from this block
  42277. * @param entry defines the element to remove
  42278. */
  42279. removeEntry(entry: T): void;
  42280. /**
  42281. * Add an array of elements to this block
  42282. * @param entries defines the array of elements to add
  42283. */
  42284. addEntries(entries: T[]): void;
  42285. /**
  42286. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42287. * @param frustumPlanes defines the frustum planes to test
  42288. * @param selection defines the array to store current content if selection is positive
  42289. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42290. */
  42291. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42292. /**
  42293. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42294. * @param sphereCenter defines the bounding sphere center
  42295. * @param sphereRadius defines the bounding sphere radius
  42296. * @param selection defines the array to store current content if selection is positive
  42297. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42298. */
  42299. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42300. /**
  42301. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42302. * @param ray defines the ray to test with
  42303. * @param selection defines the array to store current content if selection is positive
  42304. */
  42305. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42306. /**
  42307. * Subdivide the content into child blocks (this block will then be empty)
  42308. */
  42309. createInnerBlocks(): void;
  42310. /**
  42311. * @hidden
  42312. */
  42313. 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;
  42314. }
  42315. }
  42316. declare module BABYLON {
  42317. /**
  42318. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42319. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42320. */
  42321. export class Octree<T> {
  42322. /** 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.) */
  42323. maxDepth: number;
  42324. /**
  42325. * Blocks within the octree containing objects
  42326. */
  42327. blocks: Array<OctreeBlock<T>>;
  42328. /**
  42329. * Content stored in the octree
  42330. */
  42331. dynamicContent: T[];
  42332. private _maxBlockCapacity;
  42333. private _selectionContent;
  42334. private _creationFunc;
  42335. /**
  42336. * Creates a octree
  42337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42338. * @param creationFunc function to be used to instatiate the octree
  42339. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42340. * @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.)
  42341. */
  42342. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42343. /** 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.) */
  42344. maxDepth?: number);
  42345. /**
  42346. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42347. * @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);
  42348. * @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);
  42349. * @param entries meshes to be added to the octree blocks
  42350. */
  42351. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42352. /**
  42353. * Adds a mesh to the octree
  42354. * @param entry Mesh to add to the octree
  42355. */
  42356. addMesh(entry: T): void;
  42357. /**
  42358. * Remove an element from the octree
  42359. * @param entry defines the element to remove
  42360. */
  42361. removeMesh(entry: T): void;
  42362. /**
  42363. * Selects an array of meshes within the frustum
  42364. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42365. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42366. * @returns array of meshes within the frustum
  42367. */
  42368. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42369. /**
  42370. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42371. * @param sphereCenter defines the bounding sphere center
  42372. * @param sphereRadius defines the bounding sphere radius
  42373. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42374. * @returns an array of objects that intersect the sphere
  42375. */
  42376. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42377. /**
  42378. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42379. * @param ray defines the ray to test with
  42380. * @returns array of intersected objects
  42381. */
  42382. intersectsRay(ray: Ray): SmartArray<T>;
  42383. /**
  42384. * Adds a mesh into the octree block if it intersects the block
  42385. */
  42386. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42387. /**
  42388. * Adds a submesh into the octree block if it intersects the block
  42389. */
  42390. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42391. }
  42392. }
  42393. declare module BABYLON {
  42394. interface Scene {
  42395. /**
  42396. * @hidden
  42397. * Backing Filed
  42398. */
  42399. _selectionOctree: Octree<AbstractMesh>;
  42400. /**
  42401. * Gets the octree used to boost mesh selection (picking)
  42402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42403. */
  42404. selectionOctree: Octree<AbstractMesh>;
  42405. /**
  42406. * Creates or updates the octree used to boost selection (picking)
  42407. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42408. * @param maxCapacity defines the maximum capacity per leaf
  42409. * @param maxDepth defines the maximum depth of the octree
  42410. * @returns an octree of AbstractMesh
  42411. */
  42412. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42413. }
  42414. interface AbstractMesh {
  42415. /**
  42416. * @hidden
  42417. * Backing Field
  42418. */
  42419. _submeshesOctree: Octree<SubMesh>;
  42420. /**
  42421. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42422. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42423. * @param maxCapacity defines the maximum size of each block (64 by default)
  42424. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42425. * @returns the new octree
  42426. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42428. */
  42429. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42430. }
  42431. /**
  42432. * Defines the octree scene component responsible to manage any octrees
  42433. * in a given scene.
  42434. */
  42435. export class OctreeSceneComponent {
  42436. /**
  42437. * The component name help to identify the component in the list of scene components.
  42438. */
  42439. readonly name: string;
  42440. /**
  42441. * The scene the component belongs to.
  42442. */
  42443. scene: Scene;
  42444. /**
  42445. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42446. */
  42447. readonly checksIsEnabled: boolean;
  42448. /**
  42449. * Creates a new instance of the component for the given scene
  42450. * @param scene Defines the scene to register the component in
  42451. */
  42452. constructor(scene: Scene);
  42453. /**
  42454. * Registers the component in a given scene
  42455. */
  42456. register(): void;
  42457. /**
  42458. * Return the list of active meshes
  42459. * @returns the list of active meshes
  42460. */
  42461. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42462. /**
  42463. * Return the list of active sub meshes
  42464. * @param mesh The mesh to get the candidates sub meshes from
  42465. * @returns the list of active sub meshes
  42466. */
  42467. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42468. private _tempRay;
  42469. /**
  42470. * Return the list of sub meshes intersecting with a given local ray
  42471. * @param mesh defines the mesh to find the submesh for
  42472. * @param localRay defines the ray in local space
  42473. * @returns the list of intersecting sub meshes
  42474. */
  42475. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42476. /**
  42477. * Return the list of sub meshes colliding with a collider
  42478. * @param mesh defines the mesh to find the submesh for
  42479. * @param collider defines the collider to evaluate the collision against
  42480. * @returns the list of colliding sub meshes
  42481. */
  42482. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42483. /**
  42484. * Rebuilds the elements related to this component in case of
  42485. * context lost for instance.
  42486. */
  42487. rebuild(): void;
  42488. /**
  42489. * Disposes the component and the associated ressources.
  42490. */
  42491. dispose(): void;
  42492. }
  42493. }
  42494. declare module BABYLON {
  42495. /**
  42496. * Renders a layer on top of an existing scene
  42497. */
  42498. export class UtilityLayerRenderer implements IDisposable {
  42499. /** the original scene that will be rendered on top of */
  42500. originalScene: Scene;
  42501. private _pointerCaptures;
  42502. private _lastPointerEvents;
  42503. private static _DefaultUtilityLayer;
  42504. private static _DefaultKeepDepthUtilityLayer;
  42505. private _sharedGizmoLight;
  42506. private _renderCamera;
  42507. /**
  42508. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42509. * @returns the camera that is used when rendering the utility layer
  42510. */
  42511. getRenderCamera(): Nullable<Camera>;
  42512. /**
  42513. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42514. * @param cam the camera that should be used when rendering the utility layer
  42515. */
  42516. setRenderCamera(cam: Nullable<Camera>): void;
  42517. /**
  42518. * @hidden
  42519. * Light which used by gizmos to get light shading
  42520. */
  42521. _getSharedGizmoLight(): HemisphericLight;
  42522. /**
  42523. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42524. */
  42525. pickUtilitySceneFirst: boolean;
  42526. /**
  42527. * 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)
  42528. */
  42529. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42530. /**
  42531. * 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)
  42532. */
  42533. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42534. /**
  42535. * The scene that is rendered on top of the original scene
  42536. */
  42537. utilityLayerScene: Scene;
  42538. /**
  42539. * If the utility layer should automatically be rendered on top of existing scene
  42540. */
  42541. shouldRender: boolean;
  42542. /**
  42543. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42544. */
  42545. onlyCheckPointerDownEvents: boolean;
  42546. /**
  42547. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42548. */
  42549. processAllEvents: boolean;
  42550. /**
  42551. * Observable raised when the pointer move from the utility layer scene to the main scene
  42552. */
  42553. onPointerOutObservable: Observable<number>;
  42554. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42555. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42556. private _afterRenderObserver;
  42557. private _sceneDisposeObserver;
  42558. private _originalPointerObserver;
  42559. /**
  42560. * Instantiates a UtilityLayerRenderer
  42561. * @param originalScene the original scene that will be rendered on top of
  42562. * @param handleEvents boolean indicating if the utility layer should handle events
  42563. */
  42564. constructor(
  42565. /** the original scene that will be rendered on top of */
  42566. originalScene: Scene, handleEvents?: boolean);
  42567. private _notifyObservers;
  42568. /**
  42569. * Renders the utility layers scene on top of the original scene
  42570. */
  42571. render(): void;
  42572. /**
  42573. * Disposes of the renderer
  42574. */
  42575. dispose(): void;
  42576. private _updateCamera;
  42577. }
  42578. }
  42579. declare module BABYLON {
  42580. /**
  42581. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42582. */
  42583. export class Gizmo implements IDisposable {
  42584. /** The utility layer the gizmo will be added to */
  42585. gizmoLayer: UtilityLayerRenderer;
  42586. /**
  42587. * The root mesh of the gizmo
  42588. */
  42589. _rootMesh: Mesh;
  42590. private _attachedMesh;
  42591. /**
  42592. * Ratio for the scale of the gizmo (Default: 1)
  42593. */
  42594. scaleRatio: number;
  42595. /**
  42596. * If a custom mesh has been set (Default: false)
  42597. */
  42598. protected _customMeshSet: boolean;
  42599. /**
  42600. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42601. * * When set, interactions will be enabled
  42602. */
  42603. attachedMesh: Nullable<AbstractMesh>;
  42604. /**
  42605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42606. * @param mesh The mesh to replace the default mesh of the gizmo
  42607. */
  42608. setCustomMesh(mesh: Mesh): void;
  42609. /**
  42610. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42611. */
  42612. updateGizmoRotationToMatchAttachedMesh: boolean;
  42613. /**
  42614. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42615. */
  42616. updateGizmoPositionToMatchAttachedMesh: boolean;
  42617. /**
  42618. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42619. */
  42620. updateScale: boolean;
  42621. protected _interactionsEnabled: boolean;
  42622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42623. private _beforeRenderObserver;
  42624. private _tempVector;
  42625. /**
  42626. * Creates a gizmo
  42627. * @param gizmoLayer The utility layer the gizmo will be added to
  42628. */
  42629. constructor(
  42630. /** The utility layer the gizmo will be added to */
  42631. gizmoLayer?: UtilityLayerRenderer);
  42632. /**
  42633. * Updates the gizmo to match the attached mesh's position/rotation
  42634. */
  42635. protected _update(): void;
  42636. /**
  42637. * Disposes of the gizmo
  42638. */
  42639. dispose(): void;
  42640. }
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * Single plane drag gizmo
  42645. */
  42646. export class PlaneDragGizmo extends Gizmo {
  42647. /**
  42648. * Drag behavior responsible for the gizmos dragging interactions
  42649. */
  42650. dragBehavior: PointerDragBehavior;
  42651. private _pointerObserver;
  42652. /**
  42653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42654. */
  42655. snapDistance: number;
  42656. /**
  42657. * Event that fires each time the gizmo snaps to a new location.
  42658. * * snapDistance is the the change in distance
  42659. */
  42660. onSnapObservable: Observable<{
  42661. snapDistance: number;
  42662. }>;
  42663. private _plane;
  42664. private _coloredMaterial;
  42665. private _hoverMaterial;
  42666. private _isEnabled;
  42667. private _parent;
  42668. /** @hidden */
  42669. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42670. /** @hidden */
  42671. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42672. /**
  42673. * Creates a PlaneDragGizmo
  42674. * @param gizmoLayer The utility layer the gizmo will be added to
  42675. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42676. * @param color The color of the gizmo
  42677. */
  42678. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42679. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42680. /**
  42681. * If the gizmo is enabled
  42682. */
  42683. isEnabled: boolean;
  42684. /**
  42685. * Disposes of the gizmo
  42686. */
  42687. dispose(): void;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * Gizmo that enables dragging a mesh along 3 axis
  42693. */
  42694. export class PositionGizmo extends Gizmo {
  42695. /**
  42696. * Internal gizmo used for interactions on the x axis
  42697. */
  42698. xGizmo: AxisDragGizmo;
  42699. /**
  42700. * Internal gizmo used for interactions on the y axis
  42701. */
  42702. yGizmo: AxisDragGizmo;
  42703. /**
  42704. * Internal gizmo used for interactions on the z axis
  42705. */
  42706. zGizmo: AxisDragGizmo;
  42707. /**
  42708. * Internal gizmo used for interactions on the yz plane
  42709. */
  42710. xPlaneGizmo: PlaneDragGizmo;
  42711. /**
  42712. * Internal gizmo used for interactions on the xz plane
  42713. */
  42714. yPlaneGizmo: PlaneDragGizmo;
  42715. /**
  42716. * Internal gizmo used for interactions on the xy plane
  42717. */
  42718. zPlaneGizmo: PlaneDragGizmo;
  42719. /**
  42720. * private variables
  42721. */
  42722. private _meshAttached;
  42723. private _updateGizmoRotationToMatchAttachedMesh;
  42724. private _snapDistance;
  42725. private _scaleRatio;
  42726. /** Fires an event when any of it's sub gizmos are dragged */
  42727. onDragStartObservable: Observable<unknown>;
  42728. /** Fires an event when any of it's sub gizmos are released from dragging */
  42729. onDragEndObservable: Observable<unknown>;
  42730. /**
  42731. * If set to true, planar drag is enabled
  42732. */
  42733. private _planarGizmoEnabled;
  42734. attachedMesh: Nullable<AbstractMesh>;
  42735. /**
  42736. * Creates a PositionGizmo
  42737. * @param gizmoLayer The utility layer the gizmo will be added to
  42738. */
  42739. constructor(gizmoLayer?: UtilityLayerRenderer);
  42740. /**
  42741. * If the planar drag gizmo is enabled
  42742. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42743. */
  42744. planarGizmoEnabled: boolean;
  42745. updateGizmoRotationToMatchAttachedMesh: boolean;
  42746. /**
  42747. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42748. */
  42749. snapDistance: number;
  42750. /**
  42751. * Ratio for the scale of the gizmo (Default: 1)
  42752. */
  42753. scaleRatio: number;
  42754. /**
  42755. * Disposes of the gizmo
  42756. */
  42757. dispose(): void;
  42758. /**
  42759. * CustomMeshes are not supported by this gizmo
  42760. * @param mesh The mesh to replace the default mesh of the gizmo
  42761. */
  42762. setCustomMesh(mesh: Mesh): void;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * Single axis drag gizmo
  42768. */
  42769. export class AxisDragGizmo extends Gizmo {
  42770. /**
  42771. * Drag behavior responsible for the gizmos dragging interactions
  42772. */
  42773. dragBehavior: PointerDragBehavior;
  42774. private _pointerObserver;
  42775. /**
  42776. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42777. */
  42778. snapDistance: number;
  42779. /**
  42780. * Event that fires each time the gizmo snaps to a new location.
  42781. * * snapDistance is the the change in distance
  42782. */
  42783. onSnapObservable: Observable<{
  42784. snapDistance: number;
  42785. }>;
  42786. private _isEnabled;
  42787. private _parent;
  42788. private _arrow;
  42789. private _coloredMaterial;
  42790. private _hoverMaterial;
  42791. /** @hidden */
  42792. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42793. /** @hidden */
  42794. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42795. /**
  42796. * Creates an AxisDragGizmo
  42797. * @param gizmoLayer The utility layer the gizmo will be added to
  42798. * @param dragAxis The axis which the gizmo will be able to drag on
  42799. * @param color The color of the gizmo
  42800. */
  42801. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42802. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42803. /**
  42804. * If the gizmo is enabled
  42805. */
  42806. isEnabled: boolean;
  42807. /**
  42808. * Disposes of the gizmo
  42809. */
  42810. dispose(): void;
  42811. }
  42812. }
  42813. declare module BABYLON.Debug {
  42814. /**
  42815. * The Axes viewer will show 3 axes in a specific point in space
  42816. */
  42817. export class AxesViewer {
  42818. private _xAxis;
  42819. private _yAxis;
  42820. private _zAxis;
  42821. private _scaleLinesFactor;
  42822. private _instanced;
  42823. /**
  42824. * Gets the hosting scene
  42825. */
  42826. scene: Scene;
  42827. /**
  42828. * Gets or sets a number used to scale line length
  42829. */
  42830. scaleLines: number;
  42831. /** Gets the node hierarchy used to render x-axis */
  42832. readonly xAxis: TransformNode;
  42833. /** Gets the node hierarchy used to render y-axis */
  42834. readonly yAxis: TransformNode;
  42835. /** Gets the node hierarchy used to render z-axis */
  42836. readonly zAxis: TransformNode;
  42837. /**
  42838. * Creates a new AxesViewer
  42839. * @param scene defines the hosting scene
  42840. * @param scaleLines defines a number used to scale line length (1 by default)
  42841. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42842. * @param xAxis defines the node hierarchy used to render the x-axis
  42843. * @param yAxis defines the node hierarchy used to render the y-axis
  42844. * @param zAxis defines the node hierarchy used to render the z-axis
  42845. */
  42846. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42847. /**
  42848. * Force the viewer to update
  42849. * @param position defines the position of the viewer
  42850. * @param xaxis defines the x axis of the viewer
  42851. * @param yaxis defines the y axis of the viewer
  42852. * @param zaxis defines the z axis of the viewer
  42853. */
  42854. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42855. /**
  42856. * Creates an instance of this axes viewer.
  42857. * @returns a new axes viewer with instanced meshes
  42858. */
  42859. createInstance(): AxesViewer;
  42860. /** Releases resources */
  42861. dispose(): void;
  42862. private static _SetRenderingGroupId;
  42863. }
  42864. }
  42865. declare module BABYLON.Debug {
  42866. /**
  42867. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42868. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42869. */
  42870. export class BoneAxesViewer extends AxesViewer {
  42871. /**
  42872. * Gets or sets the target mesh where to display the axes viewer
  42873. */
  42874. mesh: Nullable<Mesh>;
  42875. /**
  42876. * Gets or sets the target bone where to display the axes viewer
  42877. */
  42878. bone: Nullable<Bone>;
  42879. /** Gets current position */
  42880. pos: Vector3;
  42881. /** Gets direction of X axis */
  42882. xaxis: Vector3;
  42883. /** Gets direction of Y axis */
  42884. yaxis: Vector3;
  42885. /** Gets direction of Z axis */
  42886. zaxis: Vector3;
  42887. /**
  42888. * Creates a new BoneAxesViewer
  42889. * @param scene defines the hosting scene
  42890. * @param bone defines the target bone
  42891. * @param mesh defines the target mesh
  42892. * @param scaleLines defines a scaling factor for line length (1 by default)
  42893. */
  42894. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42895. /**
  42896. * Force the viewer to update
  42897. */
  42898. update(): void;
  42899. /** Releases resources */
  42900. dispose(): void;
  42901. }
  42902. }
  42903. declare module BABYLON {
  42904. /**
  42905. * Interface used to define scene explorer extensibility option
  42906. */
  42907. export interface IExplorerExtensibilityOption {
  42908. /**
  42909. * Define the option label
  42910. */
  42911. label: string;
  42912. /**
  42913. * Defines the action to execute on click
  42914. */
  42915. action: (entity: any) => void;
  42916. }
  42917. /**
  42918. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42919. */
  42920. export interface IExplorerExtensibilityGroup {
  42921. /**
  42922. * Defines a predicate to test if a given type mut be extended
  42923. */
  42924. predicate: (entity: any) => boolean;
  42925. /**
  42926. * Gets the list of options added to a type
  42927. */
  42928. entries: IExplorerExtensibilityOption[];
  42929. }
  42930. /**
  42931. * Interface used to define the options to use to create the Inspector
  42932. */
  42933. export interface IInspectorOptions {
  42934. /**
  42935. * Display in overlay mode (default: false)
  42936. */
  42937. overlay?: boolean;
  42938. /**
  42939. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42940. */
  42941. globalRoot?: HTMLElement;
  42942. /**
  42943. * Display the Scene explorer
  42944. */
  42945. showExplorer?: boolean;
  42946. /**
  42947. * Display the property inspector
  42948. */
  42949. showInspector?: boolean;
  42950. /**
  42951. * Display in embed mode (both panes on the right)
  42952. */
  42953. embedMode?: boolean;
  42954. /**
  42955. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42956. */
  42957. handleResize?: boolean;
  42958. /**
  42959. * Allow the panes to popup (default: true)
  42960. */
  42961. enablePopup?: boolean;
  42962. /**
  42963. * Allow the panes to be closed by users (default: true)
  42964. */
  42965. enableClose?: boolean;
  42966. /**
  42967. * Optional list of extensibility entries
  42968. */
  42969. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42970. /**
  42971. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42972. */
  42973. inspectorURL?: string;
  42974. }
  42975. interface Scene {
  42976. /**
  42977. * @hidden
  42978. * Backing field
  42979. */
  42980. _debugLayer: DebugLayer;
  42981. /**
  42982. * Gets the debug layer (aka Inspector) associated with the scene
  42983. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42984. */
  42985. debugLayer: DebugLayer;
  42986. }
  42987. /**
  42988. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42989. * what is happening in your scene
  42990. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42991. */
  42992. export class DebugLayer {
  42993. /**
  42994. * Define the url to get the inspector script from.
  42995. * By default it uses the babylonjs CDN.
  42996. * @ignoreNaming
  42997. */
  42998. static InspectorURL: string;
  42999. private _scene;
  43000. private BJSINSPECTOR;
  43001. private _onPropertyChangedObservable?;
  43002. /**
  43003. * Observable triggered when a property is changed through the inspector.
  43004. */
  43005. readonly onPropertyChangedObservable: any;
  43006. /**
  43007. * Instantiates a new debug layer.
  43008. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43009. * what is happening in your scene
  43010. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43011. * @param scene Defines the scene to inspect
  43012. */
  43013. constructor(scene: Scene);
  43014. /** Creates the inspector window. */
  43015. private _createInspector;
  43016. /**
  43017. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43018. * @param entity defines the entity to select
  43019. * @param lineContainerTitle defines the specific block to highlight
  43020. */
  43021. select(entity: any, lineContainerTitle?: string): void;
  43022. /** Get the inspector from bundle or global */
  43023. private _getGlobalInspector;
  43024. /**
  43025. * Get if the inspector is visible or not.
  43026. * @returns true if visible otherwise, false
  43027. */
  43028. isVisible(): boolean;
  43029. /**
  43030. * Hide the inspector and close its window.
  43031. */
  43032. hide(): void;
  43033. /**
  43034. * Launch the debugLayer.
  43035. * @param config Define the configuration of the inspector
  43036. * @return a promise fulfilled when the debug layer is visible
  43037. */
  43038. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43039. }
  43040. }
  43041. declare module BABYLON {
  43042. /**
  43043. * Class containing static functions to help procedurally build meshes
  43044. */
  43045. export class BoxBuilder {
  43046. /**
  43047. * Creates a box mesh
  43048. * * The parameter `size` sets the size (float) of each box side (default 1)
  43049. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43050. * * 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)
  43051. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43053. * * 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
  43054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43055. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43056. * @param name defines the name of the mesh
  43057. * @param options defines the options used to create the mesh
  43058. * @param scene defines the hosting scene
  43059. * @returns the box mesh
  43060. */
  43061. static CreateBox(name: string, options: {
  43062. size?: number;
  43063. width?: number;
  43064. height?: number;
  43065. depth?: number;
  43066. faceUV?: Vector4[];
  43067. faceColors?: Color4[];
  43068. sideOrientation?: number;
  43069. frontUVs?: Vector4;
  43070. backUVs?: Vector4;
  43071. wrap?: boolean;
  43072. topBaseAt?: number;
  43073. bottomBaseAt?: number;
  43074. updatable?: boolean;
  43075. }, scene?: Nullable<Scene>): Mesh;
  43076. }
  43077. }
  43078. declare module BABYLON {
  43079. /**
  43080. * Class containing static functions to help procedurally build meshes
  43081. */
  43082. export class SphereBuilder {
  43083. /**
  43084. * Creates a sphere mesh
  43085. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43086. * * 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`)
  43087. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43088. * * 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
  43089. * * 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)
  43090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43091. * * 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
  43092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43093. * @param name defines the name of the mesh
  43094. * @param options defines the options used to create the mesh
  43095. * @param scene defines the hosting scene
  43096. * @returns the sphere mesh
  43097. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43098. */
  43099. static CreateSphere(name: string, options: {
  43100. segments?: number;
  43101. diameter?: number;
  43102. diameterX?: number;
  43103. diameterY?: number;
  43104. diameterZ?: number;
  43105. arc?: number;
  43106. slice?: number;
  43107. sideOrientation?: number;
  43108. frontUVs?: Vector4;
  43109. backUVs?: Vector4;
  43110. updatable?: boolean;
  43111. }, scene?: Nullable<Scene>): Mesh;
  43112. }
  43113. }
  43114. declare module BABYLON.Debug {
  43115. /**
  43116. * Used to show the physics impostor around the specific mesh
  43117. */
  43118. export class PhysicsViewer {
  43119. /** @hidden */
  43120. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43121. /** @hidden */
  43122. protected _meshes: Array<Nullable<AbstractMesh>>;
  43123. /** @hidden */
  43124. protected _scene: Nullable<Scene>;
  43125. /** @hidden */
  43126. protected _numMeshes: number;
  43127. /** @hidden */
  43128. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43129. private _renderFunction;
  43130. private _utilityLayer;
  43131. private _debugBoxMesh;
  43132. private _debugSphereMesh;
  43133. private _debugCylinderMesh;
  43134. private _debugMaterial;
  43135. private _debugMeshMeshes;
  43136. /**
  43137. * Creates a new PhysicsViewer
  43138. * @param scene defines the hosting scene
  43139. */
  43140. constructor(scene: Scene);
  43141. /** @hidden */
  43142. protected _updateDebugMeshes(): void;
  43143. /**
  43144. * Renders a specified physic impostor
  43145. * @param impostor defines the impostor to render
  43146. * @param targetMesh defines the mesh represented by the impostor
  43147. * @returns the new debug mesh used to render the impostor
  43148. */
  43149. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43150. /**
  43151. * Hides a specified physic impostor
  43152. * @param impostor defines the impostor to hide
  43153. */
  43154. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43155. private _getDebugMaterial;
  43156. private _getDebugBoxMesh;
  43157. private _getDebugSphereMesh;
  43158. private _getDebugCylinderMesh;
  43159. private _getDebugMeshMesh;
  43160. private _getDebugMesh;
  43161. /** Releases all resources */
  43162. dispose(): void;
  43163. }
  43164. }
  43165. declare module BABYLON {
  43166. /**
  43167. * Class containing static functions to help procedurally build meshes
  43168. */
  43169. export class LinesBuilder {
  43170. /**
  43171. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43172. * * 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
  43173. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43174. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43175. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43176. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43177. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43178. * * 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
  43179. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43182. * @param name defines the name of the new line system
  43183. * @param options defines the options used to create the line system
  43184. * @param scene defines the hosting scene
  43185. * @returns a new line system mesh
  43186. */
  43187. static CreateLineSystem(name: string, options: {
  43188. lines: Vector3[][];
  43189. updatable?: boolean;
  43190. instance?: Nullable<LinesMesh>;
  43191. colors?: Nullable<Color4[][]>;
  43192. useVertexAlpha?: boolean;
  43193. }, scene: Nullable<Scene>): LinesMesh;
  43194. /**
  43195. * Creates a line mesh
  43196. * 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
  43197. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43198. * * The parameter `points` is an array successive Vector3
  43199. * * 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
  43200. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43201. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43202. * * When updating an instance, remember that only point positions can change, not the number of points
  43203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43205. * @param name defines the name of the new line system
  43206. * @param options defines the options used to create the line system
  43207. * @param scene defines the hosting scene
  43208. * @returns a new line mesh
  43209. */
  43210. static CreateLines(name: string, options: {
  43211. points: Vector3[];
  43212. updatable?: boolean;
  43213. instance?: Nullable<LinesMesh>;
  43214. colors?: Color4[];
  43215. useVertexAlpha?: boolean;
  43216. }, scene?: Nullable<Scene>): LinesMesh;
  43217. /**
  43218. * Creates a dashed line mesh
  43219. * * 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
  43220. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43221. * * The parameter `points` is an array successive Vector3
  43222. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43223. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43224. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43225. * * 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
  43226. * * When updating an instance, remember that only point positions can change, not the number of points
  43227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43228. * @param name defines the name of the mesh
  43229. * @param options defines the options used to create the mesh
  43230. * @param scene defines the hosting scene
  43231. * @returns the dashed line mesh
  43232. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43233. */
  43234. static CreateDashedLines(name: string, options: {
  43235. points: Vector3[];
  43236. dashSize?: number;
  43237. gapSize?: number;
  43238. dashNb?: number;
  43239. updatable?: boolean;
  43240. instance?: LinesMesh;
  43241. }, scene?: Nullable<Scene>): LinesMesh;
  43242. }
  43243. }
  43244. declare module BABYLON {
  43245. /**
  43246. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43247. * in order to better appreciate the issue one might have.
  43248. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43249. */
  43250. export class RayHelper {
  43251. /**
  43252. * Defines the ray we are currently tryin to visualize.
  43253. */
  43254. ray: Nullable<Ray>;
  43255. private _renderPoints;
  43256. private _renderLine;
  43257. private _renderFunction;
  43258. private _scene;
  43259. private _updateToMeshFunction;
  43260. private _attachedToMesh;
  43261. private _meshSpaceDirection;
  43262. private _meshSpaceOrigin;
  43263. /**
  43264. * Helper function to create a colored helper in a scene in one line.
  43265. * @param ray Defines the ray we are currently tryin to visualize
  43266. * @param scene Defines the scene the ray is used in
  43267. * @param color Defines the color we want to see the ray in
  43268. * @returns The newly created ray helper.
  43269. */
  43270. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43271. /**
  43272. * Instantiate a new ray helper.
  43273. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43274. * in order to better appreciate the issue one might have.
  43275. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43276. * @param ray Defines the ray we are currently tryin to visualize
  43277. */
  43278. constructor(ray: Ray);
  43279. /**
  43280. * Shows the ray we are willing to debug.
  43281. * @param scene Defines the scene the ray needs to be rendered in
  43282. * @param color Defines the color the ray needs to be rendered in
  43283. */
  43284. show(scene: Scene, color?: Color3): void;
  43285. /**
  43286. * Hides the ray we are debugging.
  43287. */
  43288. hide(): void;
  43289. private _render;
  43290. /**
  43291. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43292. * @param mesh Defines the mesh we want the helper attached to
  43293. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43294. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43295. * @param length Defines the length of the ray
  43296. */
  43297. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43298. /**
  43299. * Detach the ray helper from the mesh it has previously been attached to.
  43300. */
  43301. detachFromMesh(): void;
  43302. private _updateToMesh;
  43303. /**
  43304. * Dispose the helper and release its associated resources.
  43305. */
  43306. dispose(): void;
  43307. }
  43308. }
  43309. declare module BABYLON.Debug {
  43310. /**
  43311. * Class used to render a debug view of a given skeleton
  43312. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43313. */
  43314. export class SkeletonViewer {
  43315. /** defines the skeleton to render */
  43316. skeleton: Skeleton;
  43317. /** defines the mesh attached to the skeleton */
  43318. mesh: AbstractMesh;
  43319. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43320. autoUpdateBonesMatrices: boolean;
  43321. /** defines the rendering group id to use with the viewer */
  43322. renderingGroupId: number;
  43323. /** Gets or sets the color used to render the skeleton */
  43324. color: Color3;
  43325. private _scene;
  43326. private _debugLines;
  43327. private _debugMesh;
  43328. private _isEnabled;
  43329. private _renderFunction;
  43330. private _utilityLayer;
  43331. /**
  43332. * Returns the mesh used to render the bones
  43333. */
  43334. readonly debugMesh: Nullable<LinesMesh>;
  43335. /**
  43336. * Creates a new SkeletonViewer
  43337. * @param skeleton defines the skeleton to render
  43338. * @param mesh defines the mesh attached to the skeleton
  43339. * @param scene defines the hosting scene
  43340. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43341. * @param renderingGroupId defines the rendering group id to use with the viewer
  43342. */
  43343. constructor(
  43344. /** defines the skeleton to render */
  43345. skeleton: Skeleton,
  43346. /** defines the mesh attached to the skeleton */
  43347. mesh: AbstractMesh, scene: Scene,
  43348. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43349. autoUpdateBonesMatrices?: boolean,
  43350. /** defines the rendering group id to use with the viewer */
  43351. renderingGroupId?: number);
  43352. /** Gets or sets a boolean indicating if the viewer is enabled */
  43353. isEnabled: boolean;
  43354. private _getBonePosition;
  43355. private _getLinesForBonesWithLength;
  43356. private _getLinesForBonesNoLength;
  43357. /** Update the viewer to sync with current skeleton state */
  43358. update(): void;
  43359. /** Release associated resources */
  43360. dispose(): void;
  43361. }
  43362. }
  43363. declare module BABYLON {
  43364. /**
  43365. * Options to create the null engine
  43366. */
  43367. export class NullEngineOptions {
  43368. /**
  43369. * Render width (Default: 512)
  43370. */
  43371. renderWidth: number;
  43372. /**
  43373. * Render height (Default: 256)
  43374. */
  43375. renderHeight: number;
  43376. /**
  43377. * Texture size (Default: 512)
  43378. */
  43379. textureSize: number;
  43380. /**
  43381. * If delta time between frames should be constant
  43382. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43383. */
  43384. deterministicLockstep: boolean;
  43385. /**
  43386. * Maximum about of steps between frames (Default: 4)
  43387. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43388. */
  43389. lockstepMaxSteps: number;
  43390. }
  43391. /**
  43392. * The null engine class provides support for headless version of babylon.js.
  43393. * This can be used in server side scenario or for testing purposes
  43394. */
  43395. export class NullEngine extends Engine {
  43396. private _options;
  43397. /**
  43398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43399. */
  43400. isDeterministicLockStep(): boolean;
  43401. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43402. getLockstepMaxSteps(): number;
  43403. /**
  43404. * Sets hardware scaling, used to save performance if needed
  43405. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43406. */
  43407. getHardwareScalingLevel(): number;
  43408. constructor(options?: NullEngineOptions);
  43409. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43410. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43411. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43412. getRenderWidth(useScreen?: boolean): number;
  43413. getRenderHeight(useScreen?: boolean): number;
  43414. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43415. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43416. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43417. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43418. bindSamplers(effect: Effect): void;
  43419. enableEffect(effect: Effect): void;
  43420. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43421. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43422. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43423. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43424. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43425. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43426. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43427. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43428. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43429. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43430. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43431. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43432. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43433. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43434. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43435. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43436. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43437. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43438. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43439. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43440. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43441. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43442. bindBuffers(vertexBuffers: {
  43443. [key: string]: VertexBuffer;
  43444. }, indexBuffer: DataBuffer, effect: Effect): void;
  43445. wipeCaches(bruteForce?: boolean): void;
  43446. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43447. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43448. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43449. /** @hidden */
  43450. _createTexture(): WebGLTexture;
  43451. /** @hidden */
  43452. _releaseTexture(texture: InternalTexture): void;
  43453. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  43454. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43455. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43456. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43457. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43458. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43459. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43460. areAllEffectsReady(): boolean;
  43461. /**
  43462. * @hidden
  43463. * Get the current error code of the webGL context
  43464. * @returns the error code
  43465. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43466. */
  43467. getError(): number;
  43468. /** @hidden */
  43469. _getUnpackAlignement(): number;
  43470. /** @hidden */
  43471. _unpackFlipY(value: boolean): void;
  43472. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43473. /**
  43474. * Updates a dynamic vertex buffer.
  43475. * @param vertexBuffer the vertex buffer to update
  43476. * @param data the data used to update the vertex buffer
  43477. * @param byteOffset the byte offset of the data (optional)
  43478. * @param byteLength the byte length of the data (optional)
  43479. */
  43480. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43481. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43482. /** @hidden */
  43483. _bindTexture(channel: number, texture: InternalTexture): void;
  43484. /** @hidden */
  43485. _releaseBuffer(buffer: DataBuffer): boolean;
  43486. releaseEffects(): void;
  43487. displayLoadingUI(): void;
  43488. hideLoadingUI(): void;
  43489. /** @hidden */
  43490. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43491. /** @hidden */
  43492. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43493. /** @hidden */
  43494. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43495. /** @hidden */
  43496. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43497. }
  43498. }
  43499. declare module BABYLON {
  43500. /** @hidden */
  43501. export class _OcclusionDataStorage {
  43502. /** @hidden */
  43503. occlusionInternalRetryCounter: number;
  43504. /** @hidden */
  43505. isOcclusionQueryInProgress: boolean;
  43506. /** @hidden */
  43507. isOccluded: boolean;
  43508. /** @hidden */
  43509. occlusionRetryCount: number;
  43510. /** @hidden */
  43511. occlusionType: number;
  43512. /** @hidden */
  43513. occlusionQueryAlgorithmType: number;
  43514. }
  43515. interface Engine {
  43516. /**
  43517. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43518. * @return the new query
  43519. */
  43520. createQuery(): WebGLQuery;
  43521. /**
  43522. * Delete and release a webGL query
  43523. * @param query defines the query to delete
  43524. * @return the current engine
  43525. */
  43526. deleteQuery(query: WebGLQuery): Engine;
  43527. /**
  43528. * Check if a given query has resolved and got its value
  43529. * @param query defines the query to check
  43530. * @returns true if the query got its value
  43531. */
  43532. isQueryResultAvailable(query: WebGLQuery): boolean;
  43533. /**
  43534. * Gets the value of a given query
  43535. * @param query defines the query to check
  43536. * @returns the value of the query
  43537. */
  43538. getQueryResult(query: WebGLQuery): number;
  43539. /**
  43540. * Initiates an occlusion query
  43541. * @param algorithmType defines the algorithm to use
  43542. * @param query defines the query to use
  43543. * @returns the current engine
  43544. * @see http://doc.babylonjs.com/features/occlusionquery
  43545. */
  43546. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43547. /**
  43548. * Ends an occlusion query
  43549. * @see http://doc.babylonjs.com/features/occlusionquery
  43550. * @param algorithmType defines the algorithm to use
  43551. * @returns the current engine
  43552. */
  43553. endOcclusionQuery(algorithmType: number): Engine;
  43554. /**
  43555. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43556. * Please note that only one query can be issued at a time
  43557. * @returns a time token used to track the time span
  43558. */
  43559. startTimeQuery(): Nullable<_TimeToken>;
  43560. /**
  43561. * Ends a time query
  43562. * @param token defines the token used to measure the time span
  43563. * @returns the time spent (in ns)
  43564. */
  43565. endTimeQuery(token: _TimeToken): int;
  43566. /** @hidden */
  43567. _currentNonTimestampToken: Nullable<_TimeToken>;
  43568. /** @hidden */
  43569. _createTimeQuery(): WebGLQuery;
  43570. /** @hidden */
  43571. _deleteTimeQuery(query: WebGLQuery): void;
  43572. /** @hidden */
  43573. _getGlAlgorithmType(algorithmType: number): number;
  43574. /** @hidden */
  43575. _getTimeQueryResult(query: WebGLQuery): any;
  43576. /** @hidden */
  43577. _getTimeQueryAvailability(query: WebGLQuery): any;
  43578. }
  43579. interface AbstractMesh {
  43580. /**
  43581. * Backing filed
  43582. * @hidden
  43583. */
  43584. __occlusionDataStorage: _OcclusionDataStorage;
  43585. /**
  43586. * Access property
  43587. * @hidden
  43588. */
  43589. _occlusionDataStorage: _OcclusionDataStorage;
  43590. /**
  43591. * 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.
  43592. * The default value is -1 which means don't break the query and wait till the result
  43593. * @see http://doc.babylonjs.com/features/occlusionquery
  43594. */
  43595. occlusionRetryCount: number;
  43596. /**
  43597. * 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:
  43598. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43599. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43600. * * 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.
  43601. * @see http://doc.babylonjs.com/features/occlusionquery
  43602. */
  43603. occlusionType: number;
  43604. /**
  43605. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43606. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43607. * * 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.
  43608. * @see http://doc.babylonjs.com/features/occlusionquery
  43609. */
  43610. occlusionQueryAlgorithmType: number;
  43611. /**
  43612. * 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
  43613. * @see http://doc.babylonjs.com/features/occlusionquery
  43614. */
  43615. isOccluded: boolean;
  43616. /**
  43617. * Flag to check the progress status of the query
  43618. * @see http://doc.babylonjs.com/features/occlusionquery
  43619. */
  43620. isOcclusionQueryInProgress: boolean;
  43621. }
  43622. }
  43623. declare module BABYLON {
  43624. /** @hidden */
  43625. export var _forceTransformFeedbackToBundle: boolean;
  43626. interface Engine {
  43627. /**
  43628. * Creates a webGL transform feedback object
  43629. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43630. * @returns the webGL transform feedback object
  43631. */
  43632. createTransformFeedback(): WebGLTransformFeedback;
  43633. /**
  43634. * Delete a webGL transform feedback object
  43635. * @param value defines the webGL transform feedback object to delete
  43636. */
  43637. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43638. /**
  43639. * Bind a webGL transform feedback object to the webgl context
  43640. * @param value defines the webGL transform feedback object to bind
  43641. */
  43642. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43643. /**
  43644. * Begins a transform feedback operation
  43645. * @param usePoints defines if points or triangles must be used
  43646. */
  43647. beginTransformFeedback(usePoints: boolean): void;
  43648. /**
  43649. * Ends a transform feedback operation
  43650. */
  43651. endTransformFeedback(): void;
  43652. /**
  43653. * Specify the varyings to use with transform feedback
  43654. * @param program defines the associated webGL program
  43655. * @param value defines the list of strings representing the varying names
  43656. */
  43657. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43658. /**
  43659. * Bind a webGL buffer for a transform feedback operation
  43660. * @param value defines the webGL buffer to bind
  43661. */
  43662. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43663. }
  43664. }
  43665. declare module BABYLON {
  43666. /**
  43667. * Creation options of the multi render target texture.
  43668. */
  43669. export interface IMultiRenderTargetOptions {
  43670. /**
  43671. * Define if the texture needs to create mip maps after render.
  43672. */
  43673. generateMipMaps?: boolean;
  43674. /**
  43675. * Define the types of all the draw buffers we want to create
  43676. */
  43677. types?: number[];
  43678. /**
  43679. * Define the sampling modes of all the draw buffers we want to create
  43680. */
  43681. samplingModes?: number[];
  43682. /**
  43683. * Define if a depth buffer is required
  43684. */
  43685. generateDepthBuffer?: boolean;
  43686. /**
  43687. * Define if a stencil buffer is required
  43688. */
  43689. generateStencilBuffer?: boolean;
  43690. /**
  43691. * Define if a depth texture is required instead of a depth buffer
  43692. */
  43693. generateDepthTexture?: boolean;
  43694. /**
  43695. * Define the number of desired draw buffers
  43696. */
  43697. textureCount?: number;
  43698. /**
  43699. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43700. */
  43701. doNotChangeAspectRatio?: boolean;
  43702. /**
  43703. * Define the default type of the buffers we are creating
  43704. */
  43705. defaultType?: number;
  43706. }
  43707. /**
  43708. * A multi render target, like a render target provides the ability to render to a texture.
  43709. * Unlike the render target, it can render to several draw buffers in one draw.
  43710. * This is specially interesting in deferred rendering or for any effects requiring more than
  43711. * just one color from a single pass.
  43712. */
  43713. export class MultiRenderTarget extends RenderTargetTexture {
  43714. private _internalTextures;
  43715. private _textures;
  43716. private _multiRenderTargetOptions;
  43717. /**
  43718. * Get if draw buffers are currently supported by the used hardware and browser.
  43719. */
  43720. readonly isSupported: boolean;
  43721. /**
  43722. * Get the list of textures generated by the multi render target.
  43723. */
  43724. readonly textures: Texture[];
  43725. /**
  43726. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43727. */
  43728. readonly depthTexture: Texture;
  43729. /**
  43730. * Set the wrapping mode on U of all the textures we are rendering to.
  43731. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43732. */
  43733. wrapU: number;
  43734. /**
  43735. * Set the wrapping mode on V of all the textures we are rendering to.
  43736. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43737. */
  43738. wrapV: number;
  43739. /**
  43740. * Instantiate a new multi render target texture.
  43741. * A multi render target, like a render target provides the ability to render to a texture.
  43742. * Unlike the render target, it can render to several draw buffers in one draw.
  43743. * This is specially interesting in deferred rendering or for any effects requiring more than
  43744. * just one color from a single pass.
  43745. * @param name Define the name of the texture
  43746. * @param size Define the size of the buffers to render to
  43747. * @param count Define the number of target we are rendering into
  43748. * @param scene Define the scene the texture belongs to
  43749. * @param options Define the options used to create the multi render target
  43750. */
  43751. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43752. /** @hidden */
  43753. _rebuild(): void;
  43754. private _createInternalTextures;
  43755. private _createTextures;
  43756. /**
  43757. * Define the number of samples used if MSAA is enabled.
  43758. */
  43759. samples: number;
  43760. /**
  43761. * Resize all the textures in the multi render target.
  43762. * Be carrefull as it will recreate all the data in the new texture.
  43763. * @param size Define the new size
  43764. */
  43765. resize(size: any): void;
  43766. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43767. /**
  43768. * Dispose the render targets and their associated resources
  43769. */
  43770. dispose(): void;
  43771. /**
  43772. * Release all the underlying texture used as draw buffers.
  43773. */
  43774. releaseInternalTextures(): void;
  43775. }
  43776. }
  43777. declare module BABYLON {
  43778. interface Engine {
  43779. /**
  43780. * Unbind a list of render target textures from the webGL context
  43781. * This is used only when drawBuffer extension or webGL2 are active
  43782. * @param textures defines the render target textures to unbind
  43783. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43784. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43785. */
  43786. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43787. /**
  43788. * Create a multi render target texture
  43789. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43790. * @param size defines the size of the texture
  43791. * @param options defines the creation options
  43792. * @returns the cube texture as an InternalTexture
  43793. */
  43794. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43795. /**
  43796. * Update the sample count for a given multiple render target texture
  43797. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43798. * @param textures defines the textures to update
  43799. * @param samples defines the sample count to set
  43800. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43801. */
  43802. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43803. }
  43804. }
  43805. declare module BABYLON {
  43806. /**
  43807. * Gather the list of clipboard event types as constants.
  43808. */
  43809. export class ClipboardEventTypes {
  43810. /**
  43811. * The clipboard event is fired when a copy command is active (pressed).
  43812. */
  43813. static readonly COPY: number;
  43814. /**
  43815. * The clipboard event is fired when a cut command is active (pressed).
  43816. */
  43817. static readonly CUT: number;
  43818. /**
  43819. * The clipboard event is fired when a paste command is active (pressed).
  43820. */
  43821. static readonly PASTE: number;
  43822. }
  43823. /**
  43824. * This class is used to store clipboard related info for the onClipboardObservable event.
  43825. */
  43826. export class ClipboardInfo {
  43827. /**
  43828. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43829. */
  43830. type: number;
  43831. /**
  43832. * Defines the related dom event
  43833. */
  43834. event: ClipboardEvent;
  43835. /**
  43836. *Creates an instance of ClipboardInfo.
  43837. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43838. * @param event Defines the related dom event
  43839. */
  43840. constructor(
  43841. /**
  43842. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43843. */
  43844. type: number,
  43845. /**
  43846. * Defines the related dom event
  43847. */
  43848. event: ClipboardEvent);
  43849. /**
  43850. * Get the clipboard event's type from the keycode.
  43851. * @param keyCode Defines the keyCode for the current keyboard event.
  43852. * @return {number}
  43853. */
  43854. static GetTypeFromCharacter(keyCode: number): number;
  43855. }
  43856. }
  43857. declare module BABYLON {
  43858. /**
  43859. * Google Daydream controller
  43860. */
  43861. export class DaydreamController extends WebVRController {
  43862. /**
  43863. * Base Url for the controller model.
  43864. */
  43865. static MODEL_BASE_URL: string;
  43866. /**
  43867. * File name for the controller model.
  43868. */
  43869. static MODEL_FILENAME: string;
  43870. /**
  43871. * Gamepad Id prefix used to identify Daydream Controller.
  43872. */
  43873. static readonly GAMEPAD_ID_PREFIX: string;
  43874. /**
  43875. * Creates a new DaydreamController from a gamepad
  43876. * @param vrGamepad the gamepad that the controller should be created from
  43877. */
  43878. constructor(vrGamepad: any);
  43879. /**
  43880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43881. * @param scene scene in which to add meshes
  43882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43883. */
  43884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43885. /**
  43886. * Called once for each button that changed state since the last frame
  43887. * @param buttonIdx Which button index changed
  43888. * @param state New state of the button
  43889. * @param changes Which properties on the state changed since last frame
  43890. */
  43891. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43892. }
  43893. }
  43894. declare module BABYLON {
  43895. /**
  43896. * Gear VR Controller
  43897. */
  43898. export class GearVRController extends WebVRController {
  43899. /**
  43900. * Base Url for the controller model.
  43901. */
  43902. static MODEL_BASE_URL: string;
  43903. /**
  43904. * File name for the controller model.
  43905. */
  43906. static MODEL_FILENAME: string;
  43907. /**
  43908. * Gamepad Id prefix used to identify this controller.
  43909. */
  43910. static readonly GAMEPAD_ID_PREFIX: string;
  43911. private readonly _buttonIndexToObservableNameMap;
  43912. /**
  43913. * Creates a new GearVRController from a gamepad
  43914. * @param vrGamepad the gamepad that the controller should be created from
  43915. */
  43916. constructor(vrGamepad: any);
  43917. /**
  43918. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43919. * @param scene scene in which to add meshes
  43920. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43921. */
  43922. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43923. /**
  43924. * Called once for each button that changed state since the last frame
  43925. * @param buttonIdx Which button index changed
  43926. * @param state New state of the button
  43927. * @param changes Which properties on the state changed since last frame
  43928. */
  43929. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43930. }
  43931. }
  43932. declare module BABYLON {
  43933. /**
  43934. * Class containing static functions to help procedurally build meshes
  43935. */
  43936. export class PolyhedronBuilder {
  43937. /**
  43938. * Creates a polyhedron mesh
  43939. * * 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
  43940. * * The parameter `size` (positive float, default 1) sets the polygon size
  43941. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43942. * * 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`
  43943. * * 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
  43944. * * 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)`)
  43945. * * 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
  43946. * * 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
  43947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43948. * * 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
  43949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43950. * @param name defines the name of the mesh
  43951. * @param options defines the options used to create the mesh
  43952. * @param scene defines the hosting scene
  43953. * @returns the polyhedron mesh
  43954. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43955. */
  43956. static CreatePolyhedron(name: string, options: {
  43957. type?: number;
  43958. size?: number;
  43959. sizeX?: number;
  43960. sizeY?: number;
  43961. sizeZ?: number;
  43962. custom?: any;
  43963. faceUV?: Vector4[];
  43964. faceColors?: Color4[];
  43965. flat?: boolean;
  43966. updatable?: boolean;
  43967. sideOrientation?: number;
  43968. frontUVs?: Vector4;
  43969. backUVs?: Vector4;
  43970. }, scene?: Nullable<Scene>): Mesh;
  43971. }
  43972. }
  43973. declare module BABYLON {
  43974. /**
  43975. * Gizmo that enables scaling a mesh along 3 axis
  43976. */
  43977. export class ScaleGizmo extends Gizmo {
  43978. /**
  43979. * Internal gizmo used for interactions on the x axis
  43980. */
  43981. xGizmo: AxisScaleGizmo;
  43982. /**
  43983. * Internal gizmo used for interactions on the y axis
  43984. */
  43985. yGizmo: AxisScaleGizmo;
  43986. /**
  43987. * Internal gizmo used for interactions on the z axis
  43988. */
  43989. zGizmo: AxisScaleGizmo;
  43990. /**
  43991. * Internal gizmo used to scale all axis equally
  43992. */
  43993. uniformScaleGizmo: AxisScaleGizmo;
  43994. private _meshAttached;
  43995. private _updateGizmoRotationToMatchAttachedMesh;
  43996. private _snapDistance;
  43997. private _scaleRatio;
  43998. private _uniformScalingMesh;
  43999. private _octahedron;
  44000. /** Fires an event when any of it's sub gizmos are dragged */
  44001. onDragStartObservable: Observable<unknown>;
  44002. /** Fires an event when any of it's sub gizmos are released from dragging */
  44003. onDragEndObservable: Observable<unknown>;
  44004. attachedMesh: Nullable<AbstractMesh>;
  44005. /**
  44006. * Creates a ScaleGizmo
  44007. * @param gizmoLayer The utility layer the gizmo will be added to
  44008. */
  44009. constructor(gizmoLayer?: UtilityLayerRenderer);
  44010. updateGizmoRotationToMatchAttachedMesh: boolean;
  44011. /**
  44012. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44013. */
  44014. snapDistance: number;
  44015. /**
  44016. * Ratio for the scale of the gizmo (Default: 1)
  44017. */
  44018. scaleRatio: number;
  44019. /**
  44020. * Disposes of the gizmo
  44021. */
  44022. dispose(): void;
  44023. }
  44024. }
  44025. declare module BABYLON {
  44026. /**
  44027. * Single axis scale gizmo
  44028. */
  44029. export class AxisScaleGizmo extends Gizmo {
  44030. /**
  44031. * Drag behavior responsible for the gizmos dragging interactions
  44032. */
  44033. dragBehavior: PointerDragBehavior;
  44034. private _pointerObserver;
  44035. /**
  44036. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44037. */
  44038. snapDistance: number;
  44039. /**
  44040. * Event that fires each time the gizmo snaps to a new location.
  44041. * * snapDistance is the the change in distance
  44042. */
  44043. onSnapObservable: Observable<{
  44044. snapDistance: number;
  44045. }>;
  44046. /**
  44047. * If the scaling operation should be done on all axis (default: false)
  44048. */
  44049. uniformScaling: boolean;
  44050. private _isEnabled;
  44051. private _parent;
  44052. private _arrow;
  44053. private _coloredMaterial;
  44054. private _hoverMaterial;
  44055. /**
  44056. * Creates an AxisScaleGizmo
  44057. * @param gizmoLayer The utility layer the gizmo will be added to
  44058. * @param dragAxis The axis which the gizmo will be able to scale on
  44059. * @param color The color of the gizmo
  44060. */
  44061. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44062. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44063. /**
  44064. * If the gizmo is enabled
  44065. */
  44066. isEnabled: boolean;
  44067. /**
  44068. * Disposes of the gizmo
  44069. */
  44070. dispose(): void;
  44071. /**
  44072. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44073. * @param mesh The mesh to replace the default mesh of the gizmo
  44074. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44075. */
  44076. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44077. }
  44078. }
  44079. declare module BABYLON {
  44080. /**
  44081. * Bounding box gizmo
  44082. */
  44083. export class BoundingBoxGizmo extends Gizmo {
  44084. private _lineBoundingBox;
  44085. private _rotateSpheresParent;
  44086. private _scaleBoxesParent;
  44087. private _boundingDimensions;
  44088. private _renderObserver;
  44089. private _pointerObserver;
  44090. private _scaleDragSpeed;
  44091. private _tmpQuaternion;
  44092. private _tmpVector;
  44093. private _tmpRotationMatrix;
  44094. /**
  44095. * 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)
  44096. */
  44097. ignoreChildren: boolean;
  44098. /**
  44099. * 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)
  44100. */
  44101. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44102. /**
  44103. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44104. */
  44105. rotationSphereSize: number;
  44106. /**
  44107. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44108. */
  44109. scaleBoxSize: number;
  44110. /**
  44111. * 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)
  44112. */
  44113. fixedDragMeshScreenSize: boolean;
  44114. /**
  44115. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44116. */
  44117. fixedDragMeshScreenSizeDistanceFactor: number;
  44118. /**
  44119. * Fired when a rotation sphere or scale box is dragged
  44120. */
  44121. onDragStartObservable: Observable<{}>;
  44122. /**
  44123. * Fired when a scale box is dragged
  44124. */
  44125. onScaleBoxDragObservable: Observable<{}>;
  44126. /**
  44127. * Fired when a scale box drag is ended
  44128. */
  44129. onScaleBoxDragEndObservable: Observable<{}>;
  44130. /**
  44131. * Fired when a rotation sphere is dragged
  44132. */
  44133. onRotationSphereDragObservable: Observable<{}>;
  44134. /**
  44135. * Fired when a rotation sphere drag is ended
  44136. */
  44137. onRotationSphereDragEndObservable: Observable<{}>;
  44138. /**
  44139. * 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)
  44140. */
  44141. scalePivot: Nullable<Vector3>;
  44142. /**
  44143. * Mesh used as a pivot to rotate the attached mesh
  44144. */
  44145. private _anchorMesh;
  44146. private _existingMeshScale;
  44147. private _dragMesh;
  44148. private pointerDragBehavior;
  44149. private coloredMaterial;
  44150. private hoverColoredMaterial;
  44151. /**
  44152. * Sets the color of the bounding box gizmo
  44153. * @param color the color to set
  44154. */
  44155. setColor(color: Color3): void;
  44156. /**
  44157. * Creates an BoundingBoxGizmo
  44158. * @param gizmoLayer The utility layer the gizmo will be added to
  44159. * @param color The color of the gizmo
  44160. */
  44161. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44163. private _selectNode;
  44164. /**
  44165. * Updates the bounding box information for the Gizmo
  44166. */
  44167. updateBoundingBox(): void;
  44168. private _updateRotationSpheres;
  44169. private _updateScaleBoxes;
  44170. /**
  44171. * Enables rotation on the specified axis and disables rotation on the others
  44172. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44173. */
  44174. setEnabledRotationAxis(axis: string): void;
  44175. /**
  44176. * Enables/disables scaling
  44177. * @param enable if scaling should be enabled
  44178. */
  44179. setEnabledScaling(enable: boolean): void;
  44180. private _updateDummy;
  44181. /**
  44182. * Enables a pointer drag behavior on the bounding box of the gizmo
  44183. */
  44184. enableDragBehavior(): void;
  44185. /**
  44186. * Disposes of the gizmo
  44187. */
  44188. dispose(): void;
  44189. /**
  44190. * 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)
  44191. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44192. * @returns the bounding box mesh with the passed in mesh as a child
  44193. */
  44194. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44195. /**
  44196. * CustomMeshes are not supported by this gizmo
  44197. * @param mesh The mesh to replace the default mesh of the gizmo
  44198. */
  44199. setCustomMesh(mesh: Mesh): void;
  44200. }
  44201. }
  44202. declare module BABYLON {
  44203. /**
  44204. * Single plane rotation gizmo
  44205. */
  44206. export class PlaneRotationGizmo extends Gizmo {
  44207. /**
  44208. * Drag behavior responsible for the gizmos dragging interactions
  44209. */
  44210. dragBehavior: PointerDragBehavior;
  44211. private _pointerObserver;
  44212. /**
  44213. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44214. */
  44215. snapDistance: number;
  44216. /**
  44217. * Event that fires each time the gizmo snaps to a new location.
  44218. * * snapDistance is the the change in distance
  44219. */
  44220. onSnapObservable: Observable<{
  44221. snapDistance: number;
  44222. }>;
  44223. private _isEnabled;
  44224. private _parent;
  44225. /**
  44226. * Creates a PlaneRotationGizmo
  44227. * @param gizmoLayer The utility layer the gizmo will be added to
  44228. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44229. * @param color The color of the gizmo
  44230. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44231. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44232. */
  44233. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44234. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44235. /**
  44236. * If the gizmo is enabled
  44237. */
  44238. isEnabled: boolean;
  44239. /**
  44240. * Disposes of the gizmo
  44241. */
  44242. dispose(): void;
  44243. }
  44244. }
  44245. declare module BABYLON {
  44246. /**
  44247. * Gizmo that enables rotating a mesh along 3 axis
  44248. */
  44249. export class RotationGizmo extends Gizmo {
  44250. /**
  44251. * Internal gizmo used for interactions on the x axis
  44252. */
  44253. xGizmo: PlaneRotationGizmo;
  44254. /**
  44255. * Internal gizmo used for interactions on the y axis
  44256. */
  44257. yGizmo: PlaneRotationGizmo;
  44258. /**
  44259. * Internal gizmo used for interactions on the z axis
  44260. */
  44261. zGizmo: PlaneRotationGizmo;
  44262. /** Fires an event when any of it's sub gizmos are dragged */
  44263. onDragStartObservable: Observable<unknown>;
  44264. /** Fires an event when any of it's sub gizmos are released from dragging */
  44265. onDragEndObservable: Observable<unknown>;
  44266. private _meshAttached;
  44267. attachedMesh: Nullable<AbstractMesh>;
  44268. /**
  44269. * Creates a RotationGizmo
  44270. * @param gizmoLayer The utility layer the gizmo will be added to
  44271. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44272. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44273. */
  44274. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44275. updateGizmoRotationToMatchAttachedMesh: boolean;
  44276. /**
  44277. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44278. */
  44279. snapDistance: number;
  44280. /**
  44281. * Ratio for the scale of the gizmo (Default: 1)
  44282. */
  44283. scaleRatio: number;
  44284. /**
  44285. * Disposes of the gizmo
  44286. */
  44287. dispose(): void;
  44288. /**
  44289. * CustomMeshes are not supported by this gizmo
  44290. * @param mesh The mesh to replace the default mesh of the gizmo
  44291. */
  44292. setCustomMesh(mesh: Mesh): void;
  44293. }
  44294. }
  44295. declare module BABYLON {
  44296. /**
  44297. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44298. */
  44299. export class GizmoManager implements IDisposable {
  44300. private scene;
  44301. /**
  44302. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44303. */
  44304. gizmos: {
  44305. positionGizmo: Nullable<PositionGizmo>;
  44306. rotationGizmo: Nullable<RotationGizmo>;
  44307. scaleGizmo: Nullable<ScaleGizmo>;
  44308. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44309. };
  44310. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44311. clearGizmoOnEmptyPointerEvent: boolean;
  44312. /** Fires an event when the manager is attached to a mesh */
  44313. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44314. private _gizmosEnabled;
  44315. private _pointerObserver;
  44316. private _attachedMesh;
  44317. private _boundingBoxColor;
  44318. private _defaultUtilityLayer;
  44319. private _defaultKeepDepthUtilityLayer;
  44320. /**
  44321. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44322. */
  44323. boundingBoxDragBehavior: SixDofDragBehavior;
  44324. /**
  44325. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44326. */
  44327. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44328. /**
  44329. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44330. */
  44331. usePointerToAttachGizmos: boolean;
  44332. /**
  44333. * Utility layer that the bounding box gizmo belongs to
  44334. */
  44335. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44336. /**
  44337. * Utility layer that all gizmos besides bounding box belong to
  44338. */
  44339. readonly utilityLayer: UtilityLayerRenderer;
  44340. /**
  44341. * Instatiates a gizmo manager
  44342. * @param scene the scene to overlay the gizmos on top of
  44343. */
  44344. constructor(scene: Scene);
  44345. /**
  44346. * Attaches a set of gizmos to the specified mesh
  44347. * @param mesh The mesh the gizmo's should be attached to
  44348. */
  44349. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44350. /**
  44351. * If the position gizmo is enabled
  44352. */
  44353. positionGizmoEnabled: boolean;
  44354. /**
  44355. * If the rotation gizmo is enabled
  44356. */
  44357. rotationGizmoEnabled: boolean;
  44358. /**
  44359. * If the scale gizmo is enabled
  44360. */
  44361. scaleGizmoEnabled: boolean;
  44362. /**
  44363. * If the boundingBox gizmo is enabled
  44364. */
  44365. boundingBoxGizmoEnabled: boolean;
  44366. /**
  44367. * Disposes of the gizmo manager
  44368. */
  44369. dispose(): void;
  44370. }
  44371. }
  44372. declare module BABYLON {
  44373. /**
  44374. * A directional light is defined by a direction (what a surprise!).
  44375. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44376. * 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.
  44377. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44378. */
  44379. export class DirectionalLight extends ShadowLight {
  44380. private _shadowFrustumSize;
  44381. /**
  44382. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44383. */
  44384. /**
  44385. * Specifies a fix frustum size for the shadow generation.
  44386. */
  44387. shadowFrustumSize: number;
  44388. private _shadowOrthoScale;
  44389. /**
  44390. * Gets the shadow projection scale against the optimal computed one.
  44391. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44392. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44393. */
  44394. /**
  44395. * Sets the shadow projection scale against the optimal computed one.
  44396. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44397. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44398. */
  44399. shadowOrthoScale: number;
  44400. /**
  44401. * Automatically compute the projection matrix to best fit (including all the casters)
  44402. * on each frame.
  44403. */
  44404. autoUpdateExtends: boolean;
  44405. private _orthoLeft;
  44406. private _orthoRight;
  44407. private _orthoTop;
  44408. private _orthoBottom;
  44409. /**
  44410. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44411. * The directional light is emitted from everywhere in the given direction.
  44412. * It can cast shadows.
  44413. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44414. * @param name The friendly name of the light
  44415. * @param direction The direction of the light
  44416. * @param scene The scene the light belongs to
  44417. */
  44418. constructor(name: string, direction: Vector3, scene: Scene);
  44419. /**
  44420. * Returns the string "DirectionalLight".
  44421. * @return The class name
  44422. */
  44423. getClassName(): string;
  44424. /**
  44425. * Returns the integer 1.
  44426. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44427. */
  44428. getTypeID(): number;
  44429. /**
  44430. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44431. * Returns the DirectionalLight Shadow projection matrix.
  44432. */
  44433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44434. /**
  44435. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44436. * Returns the DirectionalLight Shadow projection matrix.
  44437. */
  44438. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44439. /**
  44440. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44441. * Returns the DirectionalLight Shadow projection matrix.
  44442. */
  44443. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44444. protected _buildUniformLayout(): void;
  44445. /**
  44446. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44447. * @param effect The effect to update
  44448. * @param lightIndex The index of the light in the effect to update
  44449. * @returns The directional light
  44450. */
  44451. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44452. /**
  44453. * Gets the minZ used for shadow according to both the scene and the light.
  44454. *
  44455. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44456. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44457. * @param activeCamera The camera we are returning the min for
  44458. * @returns the depth min z
  44459. */
  44460. getDepthMinZ(activeCamera: Camera): number;
  44461. /**
  44462. * Gets the maxZ used for shadow according to both the scene and the light.
  44463. *
  44464. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44465. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44466. * @param activeCamera The camera we are returning the max for
  44467. * @returns the depth max z
  44468. */
  44469. getDepthMaxZ(activeCamera: Camera): number;
  44470. /**
  44471. * Prepares the list of defines specific to the light type.
  44472. * @param defines the list of defines
  44473. * @param lightIndex defines the index of the light for the effect
  44474. */
  44475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44476. }
  44477. }
  44478. declare module BABYLON {
  44479. /**
  44480. * Class containing static functions to help procedurally build meshes
  44481. */
  44482. export class HemisphereBuilder {
  44483. /**
  44484. * Creates a hemisphere mesh
  44485. * @param name defines the name of the mesh
  44486. * @param options defines the options used to create the mesh
  44487. * @param scene defines the hosting scene
  44488. * @returns the hemisphere mesh
  44489. */
  44490. static CreateHemisphere(name: string, options: {
  44491. segments?: number;
  44492. diameter?: number;
  44493. sideOrientation?: number;
  44494. }, scene: any): Mesh;
  44495. }
  44496. }
  44497. declare module BABYLON {
  44498. /**
  44499. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44500. * These values define a cone of light starting from the position, emitting toward the direction.
  44501. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44502. * and the exponent defines the speed of the decay of the light with distance (reach).
  44503. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44504. */
  44505. export class SpotLight extends ShadowLight {
  44506. private _angle;
  44507. private _innerAngle;
  44508. private _cosHalfAngle;
  44509. private _lightAngleScale;
  44510. private _lightAngleOffset;
  44511. /**
  44512. * Gets the cone angle of the spot light in Radians.
  44513. */
  44514. /**
  44515. * Sets the cone angle of the spot light in Radians.
  44516. */
  44517. angle: number;
  44518. /**
  44519. * Only used in gltf falloff mode, this defines the angle where
  44520. * the directional falloff will start before cutting at angle which could be seen
  44521. * as outer angle.
  44522. */
  44523. /**
  44524. * Only used in gltf falloff mode, this defines the angle where
  44525. * the directional falloff will start before cutting at angle which could be seen
  44526. * as outer angle.
  44527. */
  44528. innerAngle: number;
  44529. private _shadowAngleScale;
  44530. /**
  44531. * Allows scaling the angle of the light for shadow generation only.
  44532. */
  44533. /**
  44534. * Allows scaling the angle of the light for shadow generation only.
  44535. */
  44536. shadowAngleScale: number;
  44537. /**
  44538. * The light decay speed with the distance from the emission spot.
  44539. */
  44540. exponent: number;
  44541. private _projectionTextureMatrix;
  44542. /**
  44543. * Allows reading the projecton texture
  44544. */
  44545. readonly projectionTextureMatrix: Matrix;
  44546. protected _projectionTextureLightNear: number;
  44547. /**
  44548. * Gets the near clip of the Spotlight for texture projection.
  44549. */
  44550. /**
  44551. * Sets the near clip of the Spotlight for texture projection.
  44552. */
  44553. projectionTextureLightNear: number;
  44554. protected _projectionTextureLightFar: number;
  44555. /**
  44556. * Gets the far clip of the Spotlight for texture projection.
  44557. */
  44558. /**
  44559. * Sets the far clip of the Spotlight for texture projection.
  44560. */
  44561. projectionTextureLightFar: number;
  44562. protected _projectionTextureUpDirection: Vector3;
  44563. /**
  44564. * Gets the Up vector of the Spotlight for texture projection.
  44565. */
  44566. /**
  44567. * Sets the Up vector of the Spotlight for texture projection.
  44568. */
  44569. projectionTextureUpDirection: Vector3;
  44570. private _projectionTexture;
  44571. /**
  44572. * Gets the projection texture of the light.
  44573. */
  44574. /**
  44575. * Sets the projection texture of the light.
  44576. */
  44577. projectionTexture: Nullable<BaseTexture>;
  44578. private _projectionTextureViewLightDirty;
  44579. private _projectionTextureProjectionLightDirty;
  44580. private _projectionTextureDirty;
  44581. private _projectionTextureViewTargetVector;
  44582. private _projectionTextureViewLightMatrix;
  44583. private _projectionTextureProjectionLightMatrix;
  44584. private _projectionTextureScalingMatrix;
  44585. /**
  44586. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44587. * It can cast shadows.
  44588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44589. * @param name The light friendly name
  44590. * @param position The position of the spot light in the scene
  44591. * @param direction The direction of the light in the scene
  44592. * @param angle The cone angle of the light in Radians
  44593. * @param exponent The light decay speed with the distance from the emission spot
  44594. * @param scene The scene the lights belongs to
  44595. */
  44596. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44597. /**
  44598. * Returns the string "SpotLight".
  44599. * @returns the class name
  44600. */
  44601. getClassName(): string;
  44602. /**
  44603. * Returns the integer 2.
  44604. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44605. */
  44606. getTypeID(): number;
  44607. /**
  44608. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44609. */
  44610. protected _setDirection(value: Vector3): void;
  44611. /**
  44612. * Overrides the position setter to recompute the projection texture view light Matrix.
  44613. */
  44614. protected _setPosition(value: Vector3): void;
  44615. /**
  44616. * 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.
  44617. * Returns the SpotLight.
  44618. */
  44619. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44620. protected _computeProjectionTextureViewLightMatrix(): void;
  44621. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44622. /**
  44623. * Main function for light texture projection matrix computing.
  44624. */
  44625. protected _computeProjectionTextureMatrix(): void;
  44626. protected _buildUniformLayout(): void;
  44627. private _computeAngleValues;
  44628. /**
  44629. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44630. * @param effect The effect to update
  44631. * @param lightIndex The index of the light in the effect to update
  44632. * @returns The spot light
  44633. */
  44634. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44635. /**
  44636. * Disposes the light and the associated resources.
  44637. */
  44638. dispose(): void;
  44639. /**
  44640. * Prepares the list of defines specific to the light type.
  44641. * @param defines the list of defines
  44642. * @param lightIndex defines the index of the light for the effect
  44643. */
  44644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44645. }
  44646. }
  44647. declare module BABYLON {
  44648. /**
  44649. * Gizmo that enables viewing a light
  44650. */
  44651. export class LightGizmo extends Gizmo {
  44652. private _lightMesh;
  44653. private _material;
  44654. private cachedPosition;
  44655. private cachedForward;
  44656. /**
  44657. * Creates a LightGizmo
  44658. * @param gizmoLayer The utility layer the gizmo will be added to
  44659. */
  44660. constructor(gizmoLayer?: UtilityLayerRenderer);
  44661. private _light;
  44662. /**
  44663. * The light that the gizmo is attached to
  44664. */
  44665. light: Nullable<Light>;
  44666. /**
  44667. * Gets the material used to render the light gizmo
  44668. */
  44669. readonly material: StandardMaterial;
  44670. /**
  44671. * @hidden
  44672. * Updates the gizmo to match the attached mesh's position/rotation
  44673. */
  44674. protected _update(): void;
  44675. private static _Scale;
  44676. /**
  44677. * Creates the lines for a light mesh
  44678. */
  44679. private static _createLightLines;
  44680. /**
  44681. * Disposes of the light gizmo
  44682. */
  44683. dispose(): void;
  44684. private static _CreateHemisphericLightMesh;
  44685. private static _CreatePointLightMesh;
  44686. private static _CreateSpotLightMesh;
  44687. private static _CreateDirectionalLightMesh;
  44688. }
  44689. }
  44690. declare module BABYLON {
  44691. /** @hidden */
  44692. export var backgroundFragmentDeclaration: {
  44693. name: string;
  44694. shader: string;
  44695. };
  44696. }
  44697. declare module BABYLON {
  44698. /** @hidden */
  44699. export var backgroundUboDeclaration: {
  44700. name: string;
  44701. shader: string;
  44702. };
  44703. }
  44704. declare module BABYLON {
  44705. /** @hidden */
  44706. export var backgroundPixelShader: {
  44707. name: string;
  44708. shader: string;
  44709. };
  44710. }
  44711. declare module BABYLON {
  44712. /** @hidden */
  44713. export var backgroundVertexDeclaration: {
  44714. name: string;
  44715. shader: string;
  44716. };
  44717. }
  44718. declare module BABYLON {
  44719. /** @hidden */
  44720. export var backgroundVertexShader: {
  44721. name: string;
  44722. shader: string;
  44723. };
  44724. }
  44725. declare module BABYLON {
  44726. /**
  44727. * Background material used to create an efficient environement around your scene.
  44728. */
  44729. export class BackgroundMaterial extends PushMaterial {
  44730. /**
  44731. * Standard reflectance value at parallel view angle.
  44732. */
  44733. static StandardReflectance0: number;
  44734. /**
  44735. * Standard reflectance value at grazing angle.
  44736. */
  44737. static StandardReflectance90: number;
  44738. protected _primaryColor: Color3;
  44739. /**
  44740. * Key light Color (multiply against the environement texture)
  44741. */
  44742. primaryColor: Color3;
  44743. protected __perceptualColor: Nullable<Color3>;
  44744. /**
  44745. * Experimental Internal Use Only.
  44746. *
  44747. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44748. * This acts as a helper to set the primary color to a more "human friendly" value.
  44749. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44750. * output color as close as possible from the chosen value.
  44751. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44752. * part of lighting setup.)
  44753. */
  44754. _perceptualColor: Nullable<Color3>;
  44755. protected _primaryColorShadowLevel: float;
  44756. /**
  44757. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44758. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44759. */
  44760. primaryColorShadowLevel: float;
  44761. protected _primaryColorHighlightLevel: float;
  44762. /**
  44763. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44764. * The primary color is used at the level chosen to define what the white area would look.
  44765. */
  44766. primaryColorHighlightLevel: float;
  44767. protected _reflectionTexture: Nullable<BaseTexture>;
  44768. /**
  44769. * Reflection Texture used in the material.
  44770. * Should be author in a specific way for the best result (refer to the documentation).
  44771. */
  44772. reflectionTexture: Nullable<BaseTexture>;
  44773. protected _reflectionBlur: float;
  44774. /**
  44775. * Reflection Texture level of blur.
  44776. *
  44777. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44778. * texture twice.
  44779. */
  44780. reflectionBlur: float;
  44781. protected _diffuseTexture: Nullable<BaseTexture>;
  44782. /**
  44783. * Diffuse Texture used in the material.
  44784. * Should be author in a specific way for the best result (refer to the documentation).
  44785. */
  44786. diffuseTexture: Nullable<BaseTexture>;
  44787. protected _shadowLights: Nullable<IShadowLight[]>;
  44788. /**
  44789. * Specify the list of lights casting shadow on the material.
  44790. * All scene shadow lights will be included if null.
  44791. */
  44792. shadowLights: Nullable<IShadowLight[]>;
  44793. protected _shadowLevel: float;
  44794. /**
  44795. * Helps adjusting the shadow to a softer level if required.
  44796. * 0 means black shadows and 1 means no shadows.
  44797. */
  44798. shadowLevel: float;
  44799. protected _sceneCenter: Vector3;
  44800. /**
  44801. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44802. * It is usually zero but might be interesting to modify according to your setup.
  44803. */
  44804. sceneCenter: Vector3;
  44805. protected _opacityFresnel: boolean;
  44806. /**
  44807. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44808. * This helps ensuring a nice transition when the camera goes under the ground.
  44809. */
  44810. opacityFresnel: boolean;
  44811. protected _reflectionFresnel: boolean;
  44812. /**
  44813. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44814. * This helps adding a mirror texture on the ground.
  44815. */
  44816. reflectionFresnel: boolean;
  44817. protected _reflectionFalloffDistance: number;
  44818. /**
  44819. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44820. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44821. */
  44822. reflectionFalloffDistance: number;
  44823. protected _reflectionAmount: number;
  44824. /**
  44825. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44826. */
  44827. reflectionAmount: number;
  44828. protected _reflectionReflectance0: number;
  44829. /**
  44830. * This specifies the weight of the reflection at grazing angle.
  44831. */
  44832. reflectionReflectance0: number;
  44833. protected _reflectionReflectance90: number;
  44834. /**
  44835. * This specifies the weight of the reflection at a perpendicular point of view.
  44836. */
  44837. reflectionReflectance90: number;
  44838. /**
  44839. * Sets the reflection reflectance fresnel values according to the default standard
  44840. * empirically know to work well :-)
  44841. */
  44842. reflectionStandardFresnelWeight: number;
  44843. protected _useRGBColor: boolean;
  44844. /**
  44845. * Helps to directly use the maps channels instead of their level.
  44846. */
  44847. useRGBColor: boolean;
  44848. protected _enableNoise: boolean;
  44849. /**
  44850. * This helps reducing the banding effect that could occur on the background.
  44851. */
  44852. enableNoise: boolean;
  44853. /**
  44854. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44855. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44856. * Recommended to be keep at 1.0 except for special cases.
  44857. */
  44858. fovMultiplier: number;
  44859. private _fovMultiplier;
  44860. /**
  44861. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44862. */
  44863. useEquirectangularFOV: boolean;
  44864. private _maxSimultaneousLights;
  44865. /**
  44866. * Number of Simultaneous lights allowed on the material.
  44867. */
  44868. maxSimultaneousLights: int;
  44869. /**
  44870. * Default configuration related to image processing available in the Background Material.
  44871. */
  44872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44873. /**
  44874. * Keep track of the image processing observer to allow dispose and replace.
  44875. */
  44876. private _imageProcessingObserver;
  44877. /**
  44878. * Attaches a new image processing configuration to the PBR Material.
  44879. * @param configuration (if null the scene configuration will be use)
  44880. */
  44881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44882. /**
  44883. * Gets the image processing configuration used either in this material.
  44884. */
  44885. /**
  44886. * Sets the Default image processing configuration used either in the this material.
  44887. *
  44888. * If sets to null, the scene one is in use.
  44889. */
  44890. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44891. /**
  44892. * Gets wether the color curves effect is enabled.
  44893. */
  44894. /**
  44895. * Sets wether the color curves effect is enabled.
  44896. */
  44897. cameraColorCurvesEnabled: boolean;
  44898. /**
  44899. * Gets wether the color grading effect is enabled.
  44900. */
  44901. /**
  44902. * Gets wether the color grading effect is enabled.
  44903. */
  44904. cameraColorGradingEnabled: boolean;
  44905. /**
  44906. * Gets wether tonemapping is enabled or not.
  44907. */
  44908. /**
  44909. * Sets wether tonemapping is enabled or not
  44910. */
  44911. cameraToneMappingEnabled: boolean;
  44912. /**
  44913. * The camera exposure used on this material.
  44914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44915. * This corresponds to a photographic exposure.
  44916. */
  44917. /**
  44918. * The camera exposure used on this material.
  44919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44920. * This corresponds to a photographic exposure.
  44921. */
  44922. cameraExposure: float;
  44923. /**
  44924. * Gets The camera contrast used on this material.
  44925. */
  44926. /**
  44927. * Sets The camera contrast used on this material.
  44928. */
  44929. cameraContrast: float;
  44930. /**
  44931. * Gets the Color Grading 2D Lookup Texture.
  44932. */
  44933. /**
  44934. * Sets the Color Grading 2D Lookup Texture.
  44935. */
  44936. cameraColorGradingTexture: Nullable<BaseTexture>;
  44937. /**
  44938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44940. * 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;
  44941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44942. */
  44943. /**
  44944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44946. * 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;
  44947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44948. */
  44949. cameraColorCurves: Nullable<ColorCurves>;
  44950. /**
  44951. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44952. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44953. */
  44954. switchToBGR: boolean;
  44955. private _renderTargets;
  44956. private _reflectionControls;
  44957. private _white;
  44958. private _primaryShadowColor;
  44959. private _primaryHighlightColor;
  44960. /**
  44961. * Instantiates a Background Material in the given scene
  44962. * @param name The friendly name of the material
  44963. * @param scene The scene to add the material to
  44964. */
  44965. constructor(name: string, scene: Scene);
  44966. /**
  44967. * Gets a boolean indicating that current material needs to register RTT
  44968. */
  44969. readonly hasRenderTargetTextures: boolean;
  44970. /**
  44971. * The entire material has been created in order to prevent overdraw.
  44972. * @returns false
  44973. */
  44974. needAlphaTesting(): boolean;
  44975. /**
  44976. * The entire material has been created in order to prevent overdraw.
  44977. * @returns true if blending is enable
  44978. */
  44979. needAlphaBlending(): boolean;
  44980. /**
  44981. * Checks wether the material is ready to be rendered for a given mesh.
  44982. * @param mesh The mesh to render
  44983. * @param subMesh The submesh to check against
  44984. * @param useInstances Specify wether or not the material is used with instances
  44985. * @returns true if all the dependencies are ready (Textures, Effects...)
  44986. */
  44987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44988. /**
  44989. * Compute the primary color according to the chosen perceptual color.
  44990. */
  44991. private _computePrimaryColorFromPerceptualColor;
  44992. /**
  44993. * Compute the highlights and shadow colors according to their chosen levels.
  44994. */
  44995. private _computePrimaryColors;
  44996. /**
  44997. * Build the uniform buffer used in the material.
  44998. */
  44999. buildUniformLayout(): void;
  45000. /**
  45001. * Unbind the material.
  45002. */
  45003. unbind(): void;
  45004. /**
  45005. * Bind only the world matrix to the material.
  45006. * @param world The world matrix to bind.
  45007. */
  45008. bindOnlyWorldMatrix(world: Matrix): void;
  45009. /**
  45010. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45011. * @param world The world matrix to bind.
  45012. * @param subMesh The submesh to bind for.
  45013. */
  45014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45015. /**
  45016. * Checks to see if a texture is used in the material.
  45017. * @param texture - Base texture to use.
  45018. * @returns - Boolean specifying if a texture is used in the material.
  45019. */
  45020. hasTexture(texture: BaseTexture): boolean;
  45021. /**
  45022. * Dispose the material.
  45023. * @param forceDisposeEffect Force disposal of the associated effect.
  45024. * @param forceDisposeTextures Force disposal of the associated textures.
  45025. */
  45026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45027. /**
  45028. * Clones the material.
  45029. * @param name The cloned name.
  45030. * @returns The cloned material.
  45031. */
  45032. clone(name: string): BackgroundMaterial;
  45033. /**
  45034. * Serializes the current material to its JSON representation.
  45035. * @returns The JSON representation.
  45036. */
  45037. serialize(): any;
  45038. /**
  45039. * Gets the class name of the material
  45040. * @returns "BackgroundMaterial"
  45041. */
  45042. getClassName(): string;
  45043. /**
  45044. * Parse a JSON input to create back a background material.
  45045. * @param source The JSON data to parse
  45046. * @param scene The scene to create the parsed material in
  45047. * @param rootUrl The root url of the assets the material depends upon
  45048. * @returns the instantiated BackgroundMaterial.
  45049. */
  45050. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. /**
  45055. * Represents the different options available during the creation of
  45056. * a Environment helper.
  45057. *
  45058. * This can control the default ground, skybox and image processing setup of your scene.
  45059. */
  45060. export interface IEnvironmentHelperOptions {
  45061. /**
  45062. * Specifies wether or not to create a ground.
  45063. * True by default.
  45064. */
  45065. createGround: boolean;
  45066. /**
  45067. * Specifies the ground size.
  45068. * 15 by default.
  45069. */
  45070. groundSize: number;
  45071. /**
  45072. * The texture used on the ground for the main color.
  45073. * Comes from the BabylonJS CDN by default.
  45074. *
  45075. * Remarks: Can be either a texture or a url.
  45076. */
  45077. groundTexture: string | BaseTexture;
  45078. /**
  45079. * The color mixed in the ground texture by default.
  45080. * BabylonJS clearColor by default.
  45081. */
  45082. groundColor: Color3;
  45083. /**
  45084. * Specifies the ground opacity.
  45085. * 1 by default.
  45086. */
  45087. groundOpacity: number;
  45088. /**
  45089. * Enables the ground to receive shadows.
  45090. * True by default.
  45091. */
  45092. enableGroundShadow: boolean;
  45093. /**
  45094. * Helps preventing the shadow to be fully black on the ground.
  45095. * 0.5 by default.
  45096. */
  45097. groundShadowLevel: number;
  45098. /**
  45099. * Creates a mirror texture attach to the ground.
  45100. * false by default.
  45101. */
  45102. enableGroundMirror: boolean;
  45103. /**
  45104. * Specifies the ground mirror size ratio.
  45105. * 0.3 by default as the default kernel is 64.
  45106. */
  45107. groundMirrorSizeRatio: number;
  45108. /**
  45109. * Specifies the ground mirror blur kernel size.
  45110. * 64 by default.
  45111. */
  45112. groundMirrorBlurKernel: number;
  45113. /**
  45114. * Specifies the ground mirror visibility amount.
  45115. * 1 by default
  45116. */
  45117. groundMirrorAmount: number;
  45118. /**
  45119. * Specifies the ground mirror reflectance weight.
  45120. * This uses the standard weight of the background material to setup the fresnel effect
  45121. * of the mirror.
  45122. * 1 by default.
  45123. */
  45124. groundMirrorFresnelWeight: number;
  45125. /**
  45126. * Specifies the ground mirror Falloff distance.
  45127. * This can helps reducing the size of the reflection.
  45128. * 0 by Default.
  45129. */
  45130. groundMirrorFallOffDistance: number;
  45131. /**
  45132. * Specifies the ground mirror texture type.
  45133. * Unsigned Int by Default.
  45134. */
  45135. groundMirrorTextureType: number;
  45136. /**
  45137. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45138. * the shown objects.
  45139. */
  45140. groundYBias: number;
  45141. /**
  45142. * Specifies wether or not to create a skybox.
  45143. * True by default.
  45144. */
  45145. createSkybox: boolean;
  45146. /**
  45147. * Specifies the skybox size.
  45148. * 20 by default.
  45149. */
  45150. skyboxSize: number;
  45151. /**
  45152. * The texture used on the skybox for the main color.
  45153. * Comes from the BabylonJS CDN by default.
  45154. *
  45155. * Remarks: Can be either a texture or a url.
  45156. */
  45157. skyboxTexture: string | BaseTexture;
  45158. /**
  45159. * The color mixed in the skybox texture by default.
  45160. * BabylonJS clearColor by default.
  45161. */
  45162. skyboxColor: Color3;
  45163. /**
  45164. * The background rotation around the Y axis of the scene.
  45165. * This helps aligning the key lights of your scene with the background.
  45166. * 0 by default.
  45167. */
  45168. backgroundYRotation: number;
  45169. /**
  45170. * Compute automatically the size of the elements to best fit with the scene.
  45171. */
  45172. sizeAuto: boolean;
  45173. /**
  45174. * Default position of the rootMesh if autoSize is not true.
  45175. */
  45176. rootPosition: Vector3;
  45177. /**
  45178. * Sets up the image processing in the scene.
  45179. * true by default.
  45180. */
  45181. setupImageProcessing: boolean;
  45182. /**
  45183. * The texture used as your environment texture in the scene.
  45184. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45185. *
  45186. * Remarks: Can be either a texture or a url.
  45187. */
  45188. environmentTexture: string | BaseTexture;
  45189. /**
  45190. * The value of the exposure to apply to the scene.
  45191. * 0.6 by default if setupImageProcessing is true.
  45192. */
  45193. cameraExposure: number;
  45194. /**
  45195. * The value of the contrast to apply to the scene.
  45196. * 1.6 by default if setupImageProcessing is true.
  45197. */
  45198. cameraContrast: number;
  45199. /**
  45200. * Specifies wether or not tonemapping should be enabled in the scene.
  45201. * true by default if setupImageProcessing is true.
  45202. */
  45203. toneMappingEnabled: boolean;
  45204. }
  45205. /**
  45206. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45207. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45208. * It also helps with the default setup of your imageProcessing configuration.
  45209. */
  45210. export class EnvironmentHelper {
  45211. /**
  45212. * Default ground texture URL.
  45213. */
  45214. private static _groundTextureCDNUrl;
  45215. /**
  45216. * Default skybox texture URL.
  45217. */
  45218. private static _skyboxTextureCDNUrl;
  45219. /**
  45220. * Default environment texture URL.
  45221. */
  45222. private static _environmentTextureCDNUrl;
  45223. /**
  45224. * Creates the default options for the helper.
  45225. */
  45226. private static _getDefaultOptions;
  45227. private _rootMesh;
  45228. /**
  45229. * Gets the root mesh created by the helper.
  45230. */
  45231. readonly rootMesh: Mesh;
  45232. private _skybox;
  45233. /**
  45234. * Gets the skybox created by the helper.
  45235. */
  45236. readonly skybox: Nullable<Mesh>;
  45237. private _skyboxTexture;
  45238. /**
  45239. * Gets the skybox texture created by the helper.
  45240. */
  45241. readonly skyboxTexture: Nullable<BaseTexture>;
  45242. private _skyboxMaterial;
  45243. /**
  45244. * Gets the skybox material created by the helper.
  45245. */
  45246. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45247. private _ground;
  45248. /**
  45249. * Gets the ground mesh created by the helper.
  45250. */
  45251. readonly ground: Nullable<Mesh>;
  45252. private _groundTexture;
  45253. /**
  45254. * Gets the ground texture created by the helper.
  45255. */
  45256. readonly groundTexture: Nullable<BaseTexture>;
  45257. private _groundMirror;
  45258. /**
  45259. * Gets the ground mirror created by the helper.
  45260. */
  45261. readonly groundMirror: Nullable<MirrorTexture>;
  45262. /**
  45263. * Gets the ground mirror render list to helps pushing the meshes
  45264. * you wish in the ground reflection.
  45265. */
  45266. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45267. private _groundMaterial;
  45268. /**
  45269. * Gets the ground material created by the helper.
  45270. */
  45271. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45272. /**
  45273. * Stores the creation options.
  45274. */
  45275. private readonly _scene;
  45276. private _options;
  45277. /**
  45278. * This observable will be notified with any error during the creation of the environment,
  45279. * mainly texture creation errors.
  45280. */
  45281. onErrorObservable: Observable<{
  45282. message?: string;
  45283. exception?: any;
  45284. }>;
  45285. /**
  45286. * constructor
  45287. * @param options Defines the options we want to customize the helper
  45288. * @param scene The scene to add the material to
  45289. */
  45290. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45291. /**
  45292. * Updates the background according to the new options
  45293. * @param options
  45294. */
  45295. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45296. /**
  45297. * Sets the primary color of all the available elements.
  45298. * @param color the main color to affect to the ground and the background
  45299. */
  45300. setMainColor(color: Color3): void;
  45301. /**
  45302. * Setup the image processing according to the specified options.
  45303. */
  45304. private _setupImageProcessing;
  45305. /**
  45306. * Setup the environment texture according to the specified options.
  45307. */
  45308. private _setupEnvironmentTexture;
  45309. /**
  45310. * Setup the background according to the specified options.
  45311. */
  45312. private _setupBackground;
  45313. /**
  45314. * Get the scene sizes according to the setup.
  45315. */
  45316. private _getSceneSize;
  45317. /**
  45318. * Setup the ground according to the specified options.
  45319. */
  45320. private _setupGround;
  45321. /**
  45322. * Setup the ground material according to the specified options.
  45323. */
  45324. private _setupGroundMaterial;
  45325. /**
  45326. * Setup the ground diffuse texture according to the specified options.
  45327. */
  45328. private _setupGroundDiffuseTexture;
  45329. /**
  45330. * Setup the ground mirror texture according to the specified options.
  45331. */
  45332. private _setupGroundMirrorTexture;
  45333. /**
  45334. * Setup the ground to receive the mirror texture.
  45335. */
  45336. private _setupMirrorInGroundMaterial;
  45337. /**
  45338. * Setup the skybox according to the specified options.
  45339. */
  45340. private _setupSkybox;
  45341. /**
  45342. * Setup the skybox material according to the specified options.
  45343. */
  45344. private _setupSkyboxMaterial;
  45345. /**
  45346. * Setup the skybox reflection texture according to the specified options.
  45347. */
  45348. private _setupSkyboxReflectionTexture;
  45349. private _errorHandler;
  45350. /**
  45351. * Dispose all the elements created by the Helper.
  45352. */
  45353. dispose(): void;
  45354. }
  45355. }
  45356. declare module BABYLON {
  45357. /**
  45358. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45359. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45360. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45361. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45362. */
  45363. export class PhotoDome extends TransformNode {
  45364. /**
  45365. * Define the image as a Monoscopic panoramic 360 image.
  45366. */
  45367. static readonly MODE_MONOSCOPIC: number;
  45368. /**
  45369. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45370. */
  45371. static readonly MODE_TOPBOTTOM: number;
  45372. /**
  45373. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45374. */
  45375. static readonly MODE_SIDEBYSIDE: number;
  45376. private _useDirectMapping;
  45377. /**
  45378. * The texture being displayed on the sphere
  45379. */
  45380. protected _photoTexture: Texture;
  45381. /**
  45382. * Gets or sets the texture being displayed on the sphere
  45383. */
  45384. photoTexture: Texture;
  45385. /**
  45386. * Observable raised when an error occured while loading the 360 image
  45387. */
  45388. onLoadErrorObservable: Observable<string>;
  45389. /**
  45390. * The skybox material
  45391. */
  45392. protected _material: BackgroundMaterial;
  45393. /**
  45394. * The surface used for the skybox
  45395. */
  45396. protected _mesh: Mesh;
  45397. /**
  45398. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45399. * Also see the options.resolution property.
  45400. */
  45401. fovMultiplier: number;
  45402. private _imageMode;
  45403. /**
  45404. * Gets or set the current video mode for the video. It can be:
  45405. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45406. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45407. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45408. */
  45409. imageMode: number;
  45410. /**
  45411. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45412. * @param name Element's name, child elements will append suffixes for their own names.
  45413. * @param urlsOfPhoto defines the url of the photo to display
  45414. * @param options defines an object containing optional or exposed sub element properties
  45415. * @param onError defines a callback called when an error occured while loading the texture
  45416. */
  45417. constructor(name: string, urlOfPhoto: string, options: {
  45418. resolution?: number;
  45419. size?: number;
  45420. useDirectMapping?: boolean;
  45421. faceForward?: boolean;
  45422. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45423. private _onBeforeCameraRenderObserver;
  45424. private _changeImageMode;
  45425. /**
  45426. * Releases resources associated with this node.
  45427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45429. */
  45430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45431. }
  45432. }
  45433. declare module BABYLON {
  45434. /** @hidden */
  45435. export var rgbdDecodePixelShader: {
  45436. name: string;
  45437. shader: string;
  45438. };
  45439. }
  45440. declare module BABYLON {
  45441. /**
  45442. * Class used to host texture specific utilities
  45443. */
  45444. export class BRDFTextureTools {
  45445. /**
  45446. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45447. * @param texture the texture to expand.
  45448. */
  45449. private static _ExpandDefaultBRDFTexture;
  45450. /**
  45451. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45452. * @param scene defines the hosting scene
  45453. * @returns the environment BRDF texture
  45454. */
  45455. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45456. private static _environmentBRDFBase64Texture;
  45457. }
  45458. }
  45459. declare module BABYLON {
  45460. /**
  45461. * @hidden
  45462. */
  45463. export interface IMaterialClearCoatDefines {
  45464. CLEARCOAT: boolean;
  45465. CLEARCOAT_DEFAULTIOR: boolean;
  45466. CLEARCOAT_TEXTURE: boolean;
  45467. CLEARCOAT_TEXTUREDIRECTUV: number;
  45468. CLEARCOAT_BUMP: boolean;
  45469. CLEARCOAT_BUMPDIRECTUV: number;
  45470. CLEARCOAT_TINT: boolean;
  45471. CLEARCOAT_TINT_TEXTURE: boolean;
  45472. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45473. /** @hidden */
  45474. _areTexturesDirty: boolean;
  45475. }
  45476. /**
  45477. * Define the code related to the clear coat parameters of the pbr material.
  45478. */
  45479. export class PBRClearCoatConfiguration {
  45480. /**
  45481. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45482. * The default fits with a polyurethane material.
  45483. */
  45484. private static readonly _DefaultIndexOfRefraction;
  45485. private _isEnabled;
  45486. /**
  45487. * Defines if the clear coat is enabled in the material.
  45488. */
  45489. isEnabled: boolean;
  45490. /**
  45491. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45492. */
  45493. intensity: number;
  45494. /**
  45495. * Defines the clear coat layer roughness.
  45496. */
  45497. roughness: number;
  45498. private _indexOfRefraction;
  45499. /**
  45500. * Defines the index of refraction of the clear coat.
  45501. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45502. * The default fits with a polyurethane material.
  45503. * Changing the default value is more performance intensive.
  45504. */
  45505. indexOfRefraction: number;
  45506. private _texture;
  45507. /**
  45508. * Stores the clear coat values in a texture.
  45509. */
  45510. texture: Nullable<BaseTexture>;
  45511. private _bumpTexture;
  45512. /**
  45513. * Define the clear coat specific bump texture.
  45514. */
  45515. bumpTexture: Nullable<BaseTexture>;
  45516. private _isTintEnabled;
  45517. /**
  45518. * Defines if the clear coat tint is enabled in the material.
  45519. */
  45520. isTintEnabled: boolean;
  45521. /**
  45522. * Defines the clear coat tint of the material.
  45523. * This is only use if tint is enabled
  45524. */
  45525. tintColor: Color3;
  45526. /**
  45527. * Defines the distance at which the tint color should be found in the
  45528. * clear coat media.
  45529. * This is only use if tint is enabled
  45530. */
  45531. tintColorAtDistance: number;
  45532. /**
  45533. * Defines the clear coat layer thickness.
  45534. * This is only use if tint is enabled
  45535. */
  45536. tintThickness: number;
  45537. private _tintTexture;
  45538. /**
  45539. * Stores the clear tint values in a texture.
  45540. * rgb is tint
  45541. * a is a thickness factor
  45542. */
  45543. tintTexture: Nullable<BaseTexture>;
  45544. /** @hidden */
  45545. private _internalMarkAllSubMeshesAsTexturesDirty;
  45546. /** @hidden */
  45547. _markAllSubMeshesAsTexturesDirty(): void;
  45548. /**
  45549. * Instantiate a new istance of clear coat configuration.
  45550. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45551. */
  45552. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45553. /**
  45554. * Gets wehter the submesh is ready to be used or not.
  45555. * @param defines the list of "defines" to update.
  45556. * @param scene defines the scene the material belongs to.
  45557. * @param engine defines the engine the material belongs to.
  45558. * @param disableBumpMap defines wether the material disables bump or not.
  45559. * @returns - boolean indicating that the submesh is ready or not.
  45560. */
  45561. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45562. /**
  45563. * Checks to see if a texture is used in the material.
  45564. * @param defines the list of "defines" to update.
  45565. * @param scene defines the scene to the material belongs to.
  45566. */
  45567. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45568. /**
  45569. * Binds the material data.
  45570. * @param uniformBuffer defines the Uniform buffer to fill in.
  45571. * @param scene defines the scene the material belongs to.
  45572. * @param engine defines the engine the material belongs to.
  45573. * @param disableBumpMap defines wether the material disables bump or not.
  45574. * @param isFrozen defines wether the material is frozen or not.
  45575. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45576. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45577. */
  45578. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45579. /**
  45580. * Checks to see if a texture is used in the material.
  45581. * @param texture - Base texture to use.
  45582. * @returns - Boolean specifying if a texture is used in the material.
  45583. */
  45584. hasTexture(texture: BaseTexture): boolean;
  45585. /**
  45586. * Returns an array of the actively used textures.
  45587. * @param activeTextures Array of BaseTextures
  45588. */
  45589. getActiveTextures(activeTextures: BaseTexture[]): void;
  45590. /**
  45591. * Returns the animatable textures.
  45592. * @param animatables Array of animatable textures.
  45593. */
  45594. getAnimatables(animatables: IAnimatable[]): void;
  45595. /**
  45596. * Disposes the resources of the material.
  45597. * @param forceDisposeTextures - Forces the disposal of all textures.
  45598. */
  45599. dispose(forceDisposeTextures?: boolean): void;
  45600. /**
  45601. * Get the current class name of the texture useful for serialization or dynamic coding.
  45602. * @returns "PBRClearCoatConfiguration"
  45603. */
  45604. getClassName(): string;
  45605. /**
  45606. * Add fallbacks to the effect fallbacks list.
  45607. * @param defines defines the Base texture to use.
  45608. * @param fallbacks defines the current fallback list.
  45609. * @param currentRank defines the current fallback rank.
  45610. * @returns the new fallback rank.
  45611. */
  45612. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45613. /**
  45614. * Add the required uniforms to the current list.
  45615. * @param uniforms defines the current uniform list.
  45616. */
  45617. static AddUniforms(uniforms: string[]): void;
  45618. /**
  45619. * Add the required samplers to the current list.
  45620. * @param samplers defines the current sampler list.
  45621. */
  45622. static AddSamplers(samplers: string[]): void;
  45623. /**
  45624. * Add the required uniforms to the current buffer.
  45625. * @param uniformBuffer defines the current uniform buffer.
  45626. */
  45627. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45628. /**
  45629. * Makes a duplicate of the current configuration into another one.
  45630. * @param clearCoatConfiguration define the config where to copy the info
  45631. */
  45632. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45633. /**
  45634. * Serializes this clear coat configuration.
  45635. * @returns - An object with the serialized config.
  45636. */
  45637. serialize(): any;
  45638. /**
  45639. * Parses a anisotropy Configuration from a serialized object.
  45640. * @param source - Serialized object.
  45641. * @param scene Defines the scene we are parsing for
  45642. * @param rootUrl Defines the rootUrl to load from
  45643. */
  45644. parse(source: any, scene: Scene, rootUrl: string): void;
  45645. }
  45646. }
  45647. declare module BABYLON {
  45648. /**
  45649. * @hidden
  45650. */
  45651. export interface IMaterialAnisotropicDefines {
  45652. ANISOTROPIC: boolean;
  45653. ANISOTROPIC_TEXTURE: boolean;
  45654. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45655. MAINUV1: boolean;
  45656. _areTexturesDirty: boolean;
  45657. _needUVs: boolean;
  45658. }
  45659. /**
  45660. * Define the code related to the anisotropic parameters of the pbr material.
  45661. */
  45662. export class PBRAnisotropicConfiguration {
  45663. private _isEnabled;
  45664. /**
  45665. * Defines if the anisotropy is enabled in the material.
  45666. */
  45667. isEnabled: boolean;
  45668. /**
  45669. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45670. */
  45671. intensity: number;
  45672. /**
  45673. * Defines if the effect is along the tangents, bitangents or in between.
  45674. * By default, the effect is "strectching" the highlights along the tangents.
  45675. */
  45676. direction: Vector2;
  45677. private _texture;
  45678. /**
  45679. * Stores the anisotropy values in a texture.
  45680. * rg is direction (like normal from -1 to 1)
  45681. * b is a intensity
  45682. */
  45683. texture: Nullable<BaseTexture>;
  45684. /** @hidden */
  45685. private _internalMarkAllSubMeshesAsTexturesDirty;
  45686. /** @hidden */
  45687. _markAllSubMeshesAsTexturesDirty(): void;
  45688. /**
  45689. * Instantiate a new istance of anisotropy configuration.
  45690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45691. */
  45692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45693. /**
  45694. * Specifies that the submesh is ready to be used.
  45695. * @param defines the list of "defines" to update.
  45696. * @param scene defines the scene the material belongs to.
  45697. * @returns - boolean indicating that the submesh is ready or not.
  45698. */
  45699. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45700. /**
  45701. * Checks to see if a texture is used in the material.
  45702. * @param defines the list of "defines" to update.
  45703. * @param mesh the mesh we are preparing the defines for.
  45704. * @param scene defines the scene the material belongs to.
  45705. */
  45706. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45707. /**
  45708. * Binds the material data.
  45709. * @param uniformBuffer defines the Uniform buffer to fill in.
  45710. * @param scene defines the scene the material belongs to.
  45711. * @param isFrozen defines wether the material is frozen or not.
  45712. */
  45713. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45714. /**
  45715. * Checks to see if a texture is used in the material.
  45716. * @param texture - Base texture to use.
  45717. * @returns - Boolean specifying if a texture is used in the material.
  45718. */
  45719. hasTexture(texture: BaseTexture): boolean;
  45720. /**
  45721. * Returns an array of the actively used textures.
  45722. * @param activeTextures Array of BaseTextures
  45723. */
  45724. getActiveTextures(activeTextures: BaseTexture[]): void;
  45725. /**
  45726. * Returns the animatable textures.
  45727. * @param animatables Array of animatable textures.
  45728. */
  45729. getAnimatables(animatables: IAnimatable[]): void;
  45730. /**
  45731. * Disposes the resources of the material.
  45732. * @param forceDisposeTextures - Forces the disposal of all textures.
  45733. */
  45734. dispose(forceDisposeTextures?: boolean): void;
  45735. /**
  45736. * Get the current class name of the texture useful for serialization or dynamic coding.
  45737. * @returns "PBRAnisotropicConfiguration"
  45738. */
  45739. getClassName(): string;
  45740. /**
  45741. * Add fallbacks to the effect fallbacks list.
  45742. * @param defines defines the Base texture to use.
  45743. * @param fallbacks defines the current fallback list.
  45744. * @param currentRank defines the current fallback rank.
  45745. * @returns the new fallback rank.
  45746. */
  45747. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45748. /**
  45749. * Add the required uniforms to the current list.
  45750. * @param uniforms defines the current uniform list.
  45751. */
  45752. static AddUniforms(uniforms: string[]): void;
  45753. /**
  45754. * Add the required uniforms to the current buffer.
  45755. * @param uniformBuffer defines the current uniform buffer.
  45756. */
  45757. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45758. /**
  45759. * Add the required samplers to the current list.
  45760. * @param samplers defines the current sampler list.
  45761. */
  45762. static AddSamplers(samplers: string[]): void;
  45763. /**
  45764. * Makes a duplicate of the current configuration into another one.
  45765. * @param anisotropicConfiguration define the config where to copy the info
  45766. */
  45767. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45768. /**
  45769. * Serializes this anisotropy configuration.
  45770. * @returns - An object with the serialized config.
  45771. */
  45772. serialize(): any;
  45773. /**
  45774. * Parses a anisotropy Configuration from a serialized object.
  45775. * @param source - Serialized object.
  45776. * @param scene Defines the scene we are parsing for
  45777. * @param rootUrl Defines the rootUrl to load from
  45778. */
  45779. parse(source: any, scene: Scene, rootUrl: string): void;
  45780. }
  45781. }
  45782. declare module BABYLON {
  45783. /**
  45784. * @hidden
  45785. */
  45786. export interface IMaterialBRDFDefines {
  45787. BRDF_V_HEIGHT_CORRELATED: boolean;
  45788. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45789. SPHERICAL_HARMONICS: boolean;
  45790. /** @hidden */
  45791. _areMiscDirty: boolean;
  45792. }
  45793. /**
  45794. * Define the code related to the BRDF parameters of the pbr material.
  45795. */
  45796. export class PBRBRDFConfiguration {
  45797. /**
  45798. * Default value used for the energy conservation.
  45799. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45800. */
  45801. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45802. /**
  45803. * Default value used for the Smith Visibility Height Correlated mode.
  45804. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45805. */
  45806. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45807. /**
  45808. * Default value used for the IBL diffuse part.
  45809. * This can help switching back to the polynomials mode globally which is a tiny bit
  45810. * less GPU intensive at the drawback of a lower quality.
  45811. */
  45812. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45813. private _useEnergyConservation;
  45814. /**
  45815. * Defines if the material uses energy conservation.
  45816. */
  45817. useEnergyConservation: boolean;
  45818. private _useSmithVisibilityHeightCorrelated;
  45819. /**
  45820. * LEGACY Mode set to false
  45821. * Defines if the material uses height smith correlated visibility term.
  45822. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45823. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45824. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45825. * Not relying on height correlated will also disable energy conservation.
  45826. */
  45827. useSmithVisibilityHeightCorrelated: boolean;
  45828. private _useSphericalHarmonics;
  45829. /**
  45830. * LEGACY Mode set to false
  45831. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45832. * diffuse part of the IBL.
  45833. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45834. * to the ground truth.
  45835. */
  45836. useSphericalHarmonics: boolean;
  45837. /** @hidden */
  45838. private _internalMarkAllSubMeshesAsMiscDirty;
  45839. /** @hidden */
  45840. _markAllSubMeshesAsMiscDirty(): void;
  45841. /**
  45842. * Instantiate a new istance of clear coat configuration.
  45843. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45844. */
  45845. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45846. /**
  45847. * Checks to see if a texture is used in the material.
  45848. * @param defines the list of "defines" to update.
  45849. */
  45850. prepareDefines(defines: IMaterialBRDFDefines): void;
  45851. /**
  45852. * Get the current class name of the texture useful for serialization or dynamic coding.
  45853. * @returns "PBRClearCoatConfiguration"
  45854. */
  45855. getClassName(): string;
  45856. /**
  45857. * Makes a duplicate of the current configuration into another one.
  45858. * @param brdfConfiguration define the config where to copy the info
  45859. */
  45860. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45861. /**
  45862. * Serializes this BRDF configuration.
  45863. * @returns - An object with the serialized config.
  45864. */
  45865. serialize(): any;
  45866. /**
  45867. * Parses a anisotropy Configuration from a serialized object.
  45868. * @param source - Serialized object.
  45869. * @param scene Defines the scene we are parsing for
  45870. * @param rootUrl Defines the rootUrl to load from
  45871. */
  45872. parse(source: any, scene: Scene, rootUrl: string): void;
  45873. }
  45874. }
  45875. declare module BABYLON {
  45876. /**
  45877. * @hidden
  45878. */
  45879. export interface IMaterialSheenDefines {
  45880. SHEEN: boolean;
  45881. SHEEN_TEXTURE: boolean;
  45882. SHEEN_TEXTUREDIRECTUV: number;
  45883. SHEEN_LINKWITHALBEDO: boolean;
  45884. /** @hidden */
  45885. _areTexturesDirty: boolean;
  45886. }
  45887. /**
  45888. * Define the code related to the Sheen parameters of the pbr material.
  45889. */
  45890. export class PBRSheenConfiguration {
  45891. private _isEnabled;
  45892. /**
  45893. * Defines if the material uses sheen.
  45894. */
  45895. isEnabled: boolean;
  45896. private _linkSheenWithAlbedo;
  45897. /**
  45898. * Defines if the sheen is linked to the sheen color.
  45899. */
  45900. linkSheenWithAlbedo: boolean;
  45901. /**
  45902. * Defines the sheen intensity.
  45903. */
  45904. intensity: number;
  45905. /**
  45906. * Defines the sheen color.
  45907. */
  45908. color: Color3;
  45909. private _texture;
  45910. /**
  45911. * Stores the sheen tint values in a texture.
  45912. * rgb is tint
  45913. * a is a intensity
  45914. */
  45915. texture: Nullable<BaseTexture>;
  45916. /** @hidden */
  45917. private _internalMarkAllSubMeshesAsTexturesDirty;
  45918. /** @hidden */
  45919. _markAllSubMeshesAsTexturesDirty(): void;
  45920. /**
  45921. * Instantiate a new istance of clear coat configuration.
  45922. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45923. */
  45924. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45925. /**
  45926. * Specifies that the submesh is ready to be used.
  45927. * @param defines the list of "defines" to update.
  45928. * @param scene defines the scene the material belongs to.
  45929. * @returns - boolean indicating that the submesh is ready or not.
  45930. */
  45931. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45932. /**
  45933. * Checks to see if a texture is used in the material.
  45934. * @param defines the list of "defines" to update.
  45935. * @param scene defines the scene the material belongs to.
  45936. */
  45937. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45938. /**
  45939. * Binds the material data.
  45940. * @param uniformBuffer defines the Uniform buffer to fill in.
  45941. * @param scene defines the scene the material belongs to.
  45942. * @param isFrozen defines wether the material is frozen or not.
  45943. */
  45944. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45945. /**
  45946. * Checks to see if a texture is used in the material.
  45947. * @param texture - Base texture to use.
  45948. * @returns - Boolean specifying if a texture is used in the material.
  45949. */
  45950. hasTexture(texture: BaseTexture): boolean;
  45951. /**
  45952. * Returns an array of the actively used textures.
  45953. * @param activeTextures Array of BaseTextures
  45954. */
  45955. getActiveTextures(activeTextures: BaseTexture[]): void;
  45956. /**
  45957. * Returns the animatable textures.
  45958. * @param animatables Array of animatable textures.
  45959. */
  45960. getAnimatables(animatables: IAnimatable[]): void;
  45961. /**
  45962. * Disposes the resources of the material.
  45963. * @param forceDisposeTextures - Forces the disposal of all textures.
  45964. */
  45965. dispose(forceDisposeTextures?: boolean): void;
  45966. /**
  45967. * Get the current class name of the texture useful for serialization or dynamic coding.
  45968. * @returns "PBRSheenConfiguration"
  45969. */
  45970. getClassName(): string;
  45971. /**
  45972. * Add fallbacks to the effect fallbacks list.
  45973. * @param defines defines the Base texture to use.
  45974. * @param fallbacks defines the current fallback list.
  45975. * @param currentRank defines the current fallback rank.
  45976. * @returns the new fallback rank.
  45977. */
  45978. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45979. /**
  45980. * Add the required uniforms to the current list.
  45981. * @param uniforms defines the current uniform list.
  45982. */
  45983. static AddUniforms(uniforms: string[]): void;
  45984. /**
  45985. * Add the required uniforms to the current buffer.
  45986. * @param uniformBuffer defines the current uniform buffer.
  45987. */
  45988. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45989. /**
  45990. * Add the required samplers to the current list.
  45991. * @param samplers defines the current sampler list.
  45992. */
  45993. static AddSamplers(samplers: string[]): void;
  45994. /**
  45995. * Makes a duplicate of the current configuration into another one.
  45996. * @param sheenConfiguration define the config where to copy the info
  45997. */
  45998. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45999. /**
  46000. * Serializes this BRDF configuration.
  46001. * @returns - An object with the serialized config.
  46002. */
  46003. serialize(): any;
  46004. /**
  46005. * Parses a anisotropy Configuration from a serialized object.
  46006. * @param source - Serialized object.
  46007. * @param scene Defines the scene we are parsing for
  46008. * @param rootUrl Defines the rootUrl to load from
  46009. */
  46010. parse(source: any, scene: Scene, rootUrl: string): void;
  46011. }
  46012. }
  46013. declare module BABYLON {
  46014. /**
  46015. * @hidden
  46016. */
  46017. export interface IMaterialSubSurfaceDefines {
  46018. SUBSURFACE: boolean;
  46019. SS_REFRACTION: boolean;
  46020. SS_TRANSLUCENCY: boolean;
  46021. SS_SCATERRING: boolean;
  46022. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46023. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46024. SS_REFRACTIONMAP_3D: boolean;
  46025. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46026. SS_LODINREFRACTIONALPHA: boolean;
  46027. SS_GAMMAREFRACTION: boolean;
  46028. SS_RGBDREFRACTION: boolean;
  46029. SS_LINEARSPECULARREFRACTION: boolean;
  46030. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46031. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46032. /** @hidden */
  46033. _areTexturesDirty: boolean;
  46034. }
  46035. /**
  46036. * Define the code related to the sub surface parameters of the pbr material.
  46037. */
  46038. export class PBRSubSurfaceConfiguration {
  46039. private _isRefractionEnabled;
  46040. /**
  46041. * Defines if the refraction is enabled in the material.
  46042. */
  46043. isRefractionEnabled: boolean;
  46044. private _isTranslucencyEnabled;
  46045. /**
  46046. * Defines if the translucency is enabled in the material.
  46047. */
  46048. isTranslucencyEnabled: boolean;
  46049. private _isScatteringEnabled;
  46050. /**
  46051. * Defines the refraction intensity of the material.
  46052. * The refraction when enabled replaces the Diffuse part of the material.
  46053. * The intensity helps transitionning between diffuse and refraction.
  46054. */
  46055. refractionIntensity: number;
  46056. /**
  46057. * Defines the translucency intensity of the material.
  46058. * When translucency has been enabled, this defines how much of the "translucency"
  46059. * is addded to the diffuse part of the material.
  46060. */
  46061. translucencyIntensity: number;
  46062. /**
  46063. * Defines the scattering intensity of the material.
  46064. * When scattering has been enabled, this defines how much of the "scattered light"
  46065. * is addded to the diffuse part of the material.
  46066. */
  46067. scatteringIntensity: number;
  46068. private _thicknessTexture;
  46069. /**
  46070. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46071. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46072. * 0 would mean minimumThickness
  46073. * 1 would mean maximumThickness
  46074. * The other channels might be use as a mask to vary the different effects intensity.
  46075. */
  46076. thicknessTexture: Nullable<BaseTexture>;
  46077. private _refractionTexture;
  46078. /**
  46079. * Defines the texture to use for refraction.
  46080. */
  46081. refractionTexture: Nullable<BaseTexture>;
  46082. private _indexOfRefraction;
  46083. /**
  46084. * Defines the index of refraction used in the material.
  46085. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46086. */
  46087. indexOfRefraction: number;
  46088. private _invertRefractionY;
  46089. /**
  46090. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46091. */
  46092. invertRefractionY: boolean;
  46093. private _linkRefractionWithTransparency;
  46094. /**
  46095. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46096. * Materials half opaque for instance using refraction could benefit from this control.
  46097. */
  46098. linkRefractionWithTransparency: boolean;
  46099. /**
  46100. * Defines the minimum thickness stored in the thickness map.
  46101. * If no thickness map is defined, this value will be used to simulate thickness.
  46102. */
  46103. minimumThickness: number;
  46104. /**
  46105. * Defines the maximum thickness stored in the thickness map.
  46106. */
  46107. maximumThickness: number;
  46108. /**
  46109. * Defines the volume tint of the material.
  46110. * This is used for both translucency and scattering.
  46111. */
  46112. tintColor: Color3;
  46113. /**
  46114. * Defines the distance at which the tint color should be found in the media.
  46115. * This is used for refraction only.
  46116. */
  46117. tintColorAtDistance: number;
  46118. /**
  46119. * Defines how far each channel transmit through the media.
  46120. * It is defined as a color to simplify it selection.
  46121. */
  46122. diffusionDistance: Color3;
  46123. private _useMaskFromThicknessTexture;
  46124. /**
  46125. * Stores the intensity of the different subsurface effects in the thickness texture.
  46126. * * the green channel is the translucency intensity.
  46127. * * the blue channel is the scattering intensity.
  46128. * * the alpha channel is the refraction intensity.
  46129. */
  46130. useMaskFromThicknessTexture: boolean;
  46131. /** @hidden */
  46132. private _internalMarkAllSubMeshesAsTexturesDirty;
  46133. /** @hidden */
  46134. _markAllSubMeshesAsTexturesDirty(): void;
  46135. /**
  46136. * Instantiate a new istance of sub surface configuration.
  46137. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46138. */
  46139. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46140. /**
  46141. * Gets wehter the submesh is ready to be used or not.
  46142. * @param defines the list of "defines" to update.
  46143. * @param scene defines the scene the material belongs to.
  46144. * @returns - boolean indicating that the submesh is ready or not.
  46145. */
  46146. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46147. /**
  46148. * Checks to see if a texture is used in the material.
  46149. * @param defines the list of "defines" to update.
  46150. * @param scene defines the scene to the material belongs to.
  46151. */
  46152. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46153. /**
  46154. * Binds the material data.
  46155. * @param uniformBuffer defines the Uniform buffer to fill in.
  46156. * @param scene defines the scene the material belongs to.
  46157. * @param engine defines the engine the material belongs to.
  46158. * @param isFrozen defines wether the material is frozen or not.
  46159. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46160. */
  46161. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46162. /**
  46163. * Unbinds the material from the mesh.
  46164. * @param activeEffect defines the effect that should be unbound from.
  46165. * @returns true if unbound, otherwise false
  46166. */
  46167. unbind(activeEffect: Effect): boolean;
  46168. /**
  46169. * Returns the texture used for refraction or null if none is used.
  46170. * @param scene defines the scene the material belongs to.
  46171. * @returns - Refraction texture if present. If no refraction texture and refraction
  46172. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46173. */
  46174. private _getRefractionTexture;
  46175. /**
  46176. * Returns true if alpha blending should be disabled.
  46177. */
  46178. readonly disableAlphaBlending: boolean;
  46179. /**
  46180. * Fills the list of render target textures.
  46181. * @param renderTargets the list of render targets to update
  46182. */
  46183. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46184. /**
  46185. * Checks to see if a texture is used in the material.
  46186. * @param texture - Base texture to use.
  46187. * @returns - Boolean specifying if a texture is used in the material.
  46188. */
  46189. hasTexture(texture: BaseTexture): boolean;
  46190. /**
  46191. * Gets a boolean indicating that current material needs to register RTT
  46192. * @returns true if this uses a render target otherwise false.
  46193. */
  46194. hasRenderTargetTextures(): boolean;
  46195. /**
  46196. * Returns an array of the actively used textures.
  46197. * @param activeTextures Array of BaseTextures
  46198. */
  46199. getActiveTextures(activeTextures: BaseTexture[]): void;
  46200. /**
  46201. * Returns the animatable textures.
  46202. * @param animatables Array of animatable textures.
  46203. */
  46204. getAnimatables(animatables: IAnimatable[]): void;
  46205. /**
  46206. * Disposes the resources of the material.
  46207. * @param forceDisposeTextures - Forces the disposal of all textures.
  46208. */
  46209. dispose(forceDisposeTextures?: boolean): void;
  46210. /**
  46211. * Get the current class name of the texture useful for serialization or dynamic coding.
  46212. * @returns "PBRSubSurfaceConfiguration"
  46213. */
  46214. getClassName(): string;
  46215. /**
  46216. * Add fallbacks to the effect fallbacks list.
  46217. * @param defines defines the Base texture to use.
  46218. * @param fallbacks defines the current fallback list.
  46219. * @param currentRank defines the current fallback rank.
  46220. * @returns the new fallback rank.
  46221. */
  46222. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46223. /**
  46224. * Add the required uniforms to the current list.
  46225. * @param uniforms defines the current uniform list.
  46226. */
  46227. static AddUniforms(uniforms: string[]): void;
  46228. /**
  46229. * Add the required samplers to the current list.
  46230. * @param samplers defines the current sampler list.
  46231. */
  46232. static AddSamplers(samplers: string[]): void;
  46233. /**
  46234. * Add the required uniforms to the current buffer.
  46235. * @param uniformBuffer defines the current uniform buffer.
  46236. */
  46237. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46238. /**
  46239. * Makes a duplicate of the current configuration into another one.
  46240. * @param configuration define the config where to copy the info
  46241. */
  46242. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46243. /**
  46244. * Serializes this Sub Surface configuration.
  46245. * @returns - An object with the serialized config.
  46246. */
  46247. serialize(): any;
  46248. /**
  46249. * Parses a anisotropy Configuration from a serialized object.
  46250. * @param source - Serialized object.
  46251. * @param scene Defines the scene we are parsing for
  46252. * @param rootUrl Defines the rootUrl to load from
  46253. */
  46254. parse(source: any, scene: Scene, rootUrl: string): void;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /** @hidden */
  46259. export var pbrFragmentDeclaration: {
  46260. name: string;
  46261. shader: string;
  46262. };
  46263. }
  46264. declare module BABYLON {
  46265. /** @hidden */
  46266. export var pbrUboDeclaration: {
  46267. name: string;
  46268. shader: string;
  46269. };
  46270. }
  46271. declare module BABYLON {
  46272. /** @hidden */
  46273. export var pbrFragmentExtraDeclaration: {
  46274. name: string;
  46275. shader: string;
  46276. };
  46277. }
  46278. declare module BABYLON {
  46279. /** @hidden */
  46280. export var pbrFragmentSamplersDeclaration: {
  46281. name: string;
  46282. shader: string;
  46283. };
  46284. }
  46285. declare module BABYLON {
  46286. /** @hidden */
  46287. export var pbrHelperFunctions: {
  46288. name: string;
  46289. shader: string;
  46290. };
  46291. }
  46292. declare module BABYLON {
  46293. /** @hidden */
  46294. export var harmonicsFunctions: {
  46295. name: string;
  46296. shader: string;
  46297. };
  46298. }
  46299. declare module BABYLON {
  46300. /** @hidden */
  46301. export var pbrDirectLightingSetupFunctions: {
  46302. name: string;
  46303. shader: string;
  46304. };
  46305. }
  46306. declare module BABYLON {
  46307. /** @hidden */
  46308. export var pbrDirectLightingFalloffFunctions: {
  46309. name: string;
  46310. shader: string;
  46311. };
  46312. }
  46313. declare module BABYLON {
  46314. /** @hidden */
  46315. export var pbrBRDFFunctions: {
  46316. name: string;
  46317. shader: string;
  46318. };
  46319. }
  46320. declare module BABYLON {
  46321. /** @hidden */
  46322. export var pbrDirectLightingFunctions: {
  46323. name: string;
  46324. shader: string;
  46325. };
  46326. }
  46327. declare module BABYLON {
  46328. /** @hidden */
  46329. export var pbrIBLFunctions: {
  46330. name: string;
  46331. shader: string;
  46332. };
  46333. }
  46334. declare module BABYLON {
  46335. /** @hidden */
  46336. export var pbrDebug: {
  46337. name: string;
  46338. shader: string;
  46339. };
  46340. }
  46341. declare module BABYLON {
  46342. /** @hidden */
  46343. export var pbrPixelShader: {
  46344. name: string;
  46345. shader: string;
  46346. };
  46347. }
  46348. declare module BABYLON {
  46349. /** @hidden */
  46350. export var pbrVertexDeclaration: {
  46351. name: string;
  46352. shader: string;
  46353. };
  46354. }
  46355. declare module BABYLON {
  46356. /** @hidden */
  46357. export var pbrVertexShader: {
  46358. name: string;
  46359. shader: string;
  46360. };
  46361. }
  46362. declare module BABYLON {
  46363. /**
  46364. * Manages the defines for the PBR Material.
  46365. * @hidden
  46366. */
  46367. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46368. PBR: boolean;
  46369. MAINUV1: boolean;
  46370. MAINUV2: boolean;
  46371. UV1: boolean;
  46372. UV2: boolean;
  46373. ALBEDO: boolean;
  46374. ALBEDODIRECTUV: number;
  46375. VERTEXCOLOR: boolean;
  46376. AMBIENT: boolean;
  46377. AMBIENTDIRECTUV: number;
  46378. AMBIENTINGRAYSCALE: boolean;
  46379. OPACITY: boolean;
  46380. VERTEXALPHA: boolean;
  46381. OPACITYDIRECTUV: number;
  46382. OPACITYRGB: boolean;
  46383. ALPHATEST: boolean;
  46384. DEPTHPREPASS: boolean;
  46385. ALPHABLEND: boolean;
  46386. ALPHAFROMALBEDO: boolean;
  46387. ALPHATESTVALUE: string;
  46388. SPECULAROVERALPHA: boolean;
  46389. RADIANCEOVERALPHA: boolean;
  46390. ALPHAFRESNEL: boolean;
  46391. LINEARALPHAFRESNEL: boolean;
  46392. PREMULTIPLYALPHA: boolean;
  46393. EMISSIVE: boolean;
  46394. EMISSIVEDIRECTUV: number;
  46395. REFLECTIVITY: boolean;
  46396. REFLECTIVITYDIRECTUV: number;
  46397. SPECULARTERM: boolean;
  46398. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46399. MICROSURFACEAUTOMATIC: boolean;
  46400. LODBASEDMICROSFURACE: boolean;
  46401. MICROSURFACEMAP: boolean;
  46402. MICROSURFACEMAPDIRECTUV: number;
  46403. METALLICWORKFLOW: boolean;
  46404. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46405. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46406. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46407. AOSTOREINMETALMAPRED: boolean;
  46408. ENVIRONMENTBRDF: boolean;
  46409. ENVIRONMENTBRDF_RGBD: boolean;
  46410. NORMAL: boolean;
  46411. TANGENT: boolean;
  46412. BUMP: boolean;
  46413. BUMPDIRECTUV: number;
  46414. OBJECTSPACE_NORMALMAP: boolean;
  46415. PARALLAX: boolean;
  46416. PARALLAXOCCLUSION: boolean;
  46417. NORMALXYSCALE: boolean;
  46418. LIGHTMAP: boolean;
  46419. LIGHTMAPDIRECTUV: number;
  46420. USELIGHTMAPASSHADOWMAP: boolean;
  46421. GAMMALIGHTMAP: boolean;
  46422. REFLECTION: boolean;
  46423. REFLECTIONMAP_3D: boolean;
  46424. REFLECTIONMAP_SPHERICAL: boolean;
  46425. REFLECTIONMAP_PLANAR: boolean;
  46426. REFLECTIONMAP_CUBIC: boolean;
  46427. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46428. REFLECTIONMAP_PROJECTION: boolean;
  46429. REFLECTIONMAP_SKYBOX: boolean;
  46430. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46431. REFLECTIONMAP_EXPLICIT: boolean;
  46432. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46433. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46434. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46435. INVERTCUBICMAP: boolean;
  46436. USESPHERICALFROMREFLECTIONMAP: boolean;
  46437. USEIRRADIANCEMAP: boolean;
  46438. SPHERICAL_HARMONICS: boolean;
  46439. USESPHERICALINVERTEX: boolean;
  46440. REFLECTIONMAP_OPPOSITEZ: boolean;
  46441. LODINREFLECTIONALPHA: boolean;
  46442. GAMMAREFLECTION: boolean;
  46443. RGBDREFLECTION: boolean;
  46444. LINEARSPECULARREFLECTION: boolean;
  46445. RADIANCEOCCLUSION: boolean;
  46446. HORIZONOCCLUSION: boolean;
  46447. INSTANCES: boolean;
  46448. NUM_BONE_INFLUENCERS: number;
  46449. BonesPerMesh: number;
  46450. BONETEXTURE: boolean;
  46451. NONUNIFORMSCALING: boolean;
  46452. MORPHTARGETS: boolean;
  46453. MORPHTARGETS_NORMAL: boolean;
  46454. MORPHTARGETS_TANGENT: boolean;
  46455. MORPHTARGETS_UV: boolean;
  46456. NUM_MORPH_INFLUENCERS: number;
  46457. IMAGEPROCESSING: boolean;
  46458. VIGNETTE: boolean;
  46459. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46460. VIGNETTEBLENDMODEOPAQUE: boolean;
  46461. TONEMAPPING: boolean;
  46462. TONEMAPPING_ACES: boolean;
  46463. CONTRAST: boolean;
  46464. COLORCURVES: boolean;
  46465. COLORGRADING: boolean;
  46466. COLORGRADING3D: boolean;
  46467. SAMPLER3DGREENDEPTH: boolean;
  46468. SAMPLER3DBGRMAP: boolean;
  46469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46470. EXPOSURE: boolean;
  46471. MULTIVIEW: boolean;
  46472. USEPHYSICALLIGHTFALLOFF: boolean;
  46473. USEGLTFLIGHTFALLOFF: boolean;
  46474. TWOSIDEDLIGHTING: boolean;
  46475. SHADOWFLOAT: boolean;
  46476. CLIPPLANE: boolean;
  46477. CLIPPLANE2: boolean;
  46478. CLIPPLANE3: boolean;
  46479. CLIPPLANE4: boolean;
  46480. POINTSIZE: boolean;
  46481. FOG: boolean;
  46482. LOGARITHMICDEPTH: boolean;
  46483. FORCENORMALFORWARD: boolean;
  46484. SPECULARAA: boolean;
  46485. CLEARCOAT: boolean;
  46486. CLEARCOAT_DEFAULTIOR: boolean;
  46487. CLEARCOAT_TEXTURE: boolean;
  46488. CLEARCOAT_TEXTUREDIRECTUV: number;
  46489. CLEARCOAT_BUMP: boolean;
  46490. CLEARCOAT_BUMPDIRECTUV: number;
  46491. CLEARCOAT_TINT: boolean;
  46492. CLEARCOAT_TINT_TEXTURE: boolean;
  46493. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46494. ANISOTROPIC: boolean;
  46495. ANISOTROPIC_TEXTURE: boolean;
  46496. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46497. BRDF_V_HEIGHT_CORRELATED: boolean;
  46498. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46499. SHEEN: boolean;
  46500. SHEEN_TEXTURE: boolean;
  46501. SHEEN_TEXTUREDIRECTUV: number;
  46502. SHEEN_LINKWITHALBEDO: boolean;
  46503. SUBSURFACE: boolean;
  46504. SS_REFRACTION: boolean;
  46505. SS_TRANSLUCENCY: boolean;
  46506. SS_SCATERRING: boolean;
  46507. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46508. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46509. SS_REFRACTIONMAP_3D: boolean;
  46510. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46511. SS_LODINREFRACTIONALPHA: boolean;
  46512. SS_GAMMAREFRACTION: boolean;
  46513. SS_RGBDREFRACTION: boolean;
  46514. SS_LINEARSPECULARREFRACTION: boolean;
  46515. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46516. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46517. UNLIT: boolean;
  46518. DEBUGMODE: number;
  46519. /**
  46520. * Initializes the PBR Material defines.
  46521. */
  46522. constructor();
  46523. /**
  46524. * Resets the PBR Material defines.
  46525. */
  46526. reset(): void;
  46527. }
  46528. /**
  46529. * The Physically based material base class of BJS.
  46530. *
  46531. * This offers the main features of a standard PBR material.
  46532. * For more information, please refer to the documentation :
  46533. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46534. */
  46535. export abstract class PBRBaseMaterial extends PushMaterial {
  46536. /**
  46537. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46538. */
  46539. static readonly PBRMATERIAL_OPAQUE: number;
  46540. /**
  46541. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46542. */
  46543. static readonly PBRMATERIAL_ALPHATEST: number;
  46544. /**
  46545. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46546. */
  46547. static readonly PBRMATERIAL_ALPHABLEND: number;
  46548. /**
  46549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46550. * They are also discarded below the alpha cutoff threshold to improve performances.
  46551. */
  46552. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46553. /**
  46554. * Defines the default value of how much AO map is occluding the analytical lights
  46555. * (point spot...).
  46556. */
  46557. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46558. /**
  46559. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46560. */
  46561. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46562. /**
  46563. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46564. * to enhance interoperability with other engines.
  46565. */
  46566. static readonly LIGHTFALLOFF_GLTF: number;
  46567. /**
  46568. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46569. * to enhance interoperability with other materials.
  46570. */
  46571. static readonly LIGHTFALLOFF_STANDARD: number;
  46572. /**
  46573. * Intensity of the direct lights e.g. the four lights available in your scene.
  46574. * This impacts both the direct diffuse and specular highlights.
  46575. */
  46576. protected _directIntensity: number;
  46577. /**
  46578. * Intensity of the emissive part of the material.
  46579. * This helps controlling the emissive effect without modifying the emissive color.
  46580. */
  46581. protected _emissiveIntensity: number;
  46582. /**
  46583. * Intensity of the environment e.g. how much the environment will light the object
  46584. * either through harmonics for rough material or through the refelction for shiny ones.
  46585. */
  46586. protected _environmentIntensity: number;
  46587. /**
  46588. * This is a special control allowing the reduction of the specular highlights coming from the
  46589. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46590. */
  46591. protected _specularIntensity: number;
  46592. /**
  46593. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46594. */
  46595. private _lightingInfos;
  46596. /**
  46597. * Debug Control allowing disabling the bump map on this material.
  46598. */
  46599. protected _disableBumpMap: boolean;
  46600. /**
  46601. * AKA Diffuse Texture in standard nomenclature.
  46602. */
  46603. protected _albedoTexture: Nullable<BaseTexture>;
  46604. /**
  46605. * AKA Occlusion Texture in other nomenclature.
  46606. */
  46607. protected _ambientTexture: Nullable<BaseTexture>;
  46608. /**
  46609. * AKA Occlusion Texture Intensity in other nomenclature.
  46610. */
  46611. protected _ambientTextureStrength: number;
  46612. /**
  46613. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46614. * 1 means it completely occludes it
  46615. * 0 mean it has no impact
  46616. */
  46617. protected _ambientTextureImpactOnAnalyticalLights: number;
  46618. /**
  46619. * Stores the alpha values in a texture.
  46620. */
  46621. protected _opacityTexture: Nullable<BaseTexture>;
  46622. /**
  46623. * Stores the reflection values in a texture.
  46624. */
  46625. protected _reflectionTexture: Nullable<BaseTexture>;
  46626. /**
  46627. * Stores the emissive values in a texture.
  46628. */
  46629. protected _emissiveTexture: Nullable<BaseTexture>;
  46630. /**
  46631. * AKA Specular texture in other nomenclature.
  46632. */
  46633. protected _reflectivityTexture: Nullable<BaseTexture>;
  46634. /**
  46635. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46636. */
  46637. protected _metallicTexture: Nullable<BaseTexture>;
  46638. /**
  46639. * Specifies the metallic scalar of the metallic/roughness workflow.
  46640. * Can also be used to scale the metalness values of the metallic texture.
  46641. */
  46642. protected _metallic: Nullable<number>;
  46643. /**
  46644. * Specifies the roughness scalar of the metallic/roughness workflow.
  46645. * Can also be used to scale the roughness values of the metallic texture.
  46646. */
  46647. protected _roughness: Nullable<number>;
  46648. /**
  46649. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46650. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46651. */
  46652. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46653. /**
  46654. * Stores surface normal data used to displace a mesh in a texture.
  46655. */
  46656. protected _bumpTexture: Nullable<BaseTexture>;
  46657. /**
  46658. * Stores the pre-calculated light information of a mesh in a texture.
  46659. */
  46660. protected _lightmapTexture: Nullable<BaseTexture>;
  46661. /**
  46662. * The color of a material in ambient lighting.
  46663. */
  46664. protected _ambientColor: Color3;
  46665. /**
  46666. * AKA Diffuse Color in other nomenclature.
  46667. */
  46668. protected _albedoColor: Color3;
  46669. /**
  46670. * AKA Specular Color in other nomenclature.
  46671. */
  46672. protected _reflectivityColor: Color3;
  46673. /**
  46674. * The color applied when light is reflected from a material.
  46675. */
  46676. protected _reflectionColor: Color3;
  46677. /**
  46678. * The color applied when light is emitted from a material.
  46679. */
  46680. protected _emissiveColor: Color3;
  46681. /**
  46682. * AKA Glossiness in other nomenclature.
  46683. */
  46684. protected _microSurface: number;
  46685. /**
  46686. * Specifies that the material will use the light map as a show map.
  46687. */
  46688. protected _useLightmapAsShadowmap: boolean;
  46689. /**
  46690. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46691. * makes the reflect vector face the model (under horizon).
  46692. */
  46693. protected _useHorizonOcclusion: boolean;
  46694. /**
  46695. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46696. * too much the area relying on ambient texture to define their ambient occlusion.
  46697. */
  46698. protected _useRadianceOcclusion: boolean;
  46699. /**
  46700. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46701. */
  46702. protected _useAlphaFromAlbedoTexture: boolean;
  46703. /**
  46704. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46705. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46706. */
  46707. protected _useSpecularOverAlpha: boolean;
  46708. /**
  46709. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46710. */
  46711. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46712. /**
  46713. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46714. */
  46715. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46716. /**
  46717. * Specifies if the metallic texture contains the roughness information in its green channel.
  46718. */
  46719. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46720. /**
  46721. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46722. */
  46723. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46724. /**
  46725. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46726. */
  46727. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46728. /**
  46729. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46730. */
  46731. protected _useAmbientInGrayScale: boolean;
  46732. /**
  46733. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46734. * The material will try to infer what glossiness each pixel should be.
  46735. */
  46736. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46737. /**
  46738. * Defines the falloff type used in this material.
  46739. * It by default is Physical.
  46740. */
  46741. protected _lightFalloff: number;
  46742. /**
  46743. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46744. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46745. */
  46746. protected _useRadianceOverAlpha: boolean;
  46747. /**
  46748. * Allows using an object space normal map (instead of tangent space).
  46749. */
  46750. protected _useObjectSpaceNormalMap: boolean;
  46751. /**
  46752. * Allows using the bump map in parallax mode.
  46753. */
  46754. protected _useParallax: boolean;
  46755. /**
  46756. * Allows using the bump map in parallax occlusion mode.
  46757. */
  46758. protected _useParallaxOcclusion: boolean;
  46759. /**
  46760. * Controls the scale bias of the parallax mode.
  46761. */
  46762. protected _parallaxScaleBias: number;
  46763. /**
  46764. * If sets to true, disables all the lights affecting the material.
  46765. */
  46766. protected _disableLighting: boolean;
  46767. /**
  46768. * Number of Simultaneous lights allowed on the material.
  46769. */
  46770. protected _maxSimultaneousLights: number;
  46771. /**
  46772. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46773. */
  46774. protected _invertNormalMapX: boolean;
  46775. /**
  46776. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46777. */
  46778. protected _invertNormalMapY: boolean;
  46779. /**
  46780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46781. */
  46782. protected _twoSidedLighting: boolean;
  46783. /**
  46784. * Defines the alpha limits in alpha test mode.
  46785. */
  46786. protected _alphaCutOff: number;
  46787. /**
  46788. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46789. */
  46790. protected _forceAlphaTest: boolean;
  46791. /**
  46792. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46793. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46794. */
  46795. protected _useAlphaFresnel: boolean;
  46796. /**
  46797. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46798. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46799. */
  46800. protected _useLinearAlphaFresnel: boolean;
  46801. /**
  46802. * The transparency mode of the material.
  46803. */
  46804. protected _transparencyMode: Nullable<number>;
  46805. /**
  46806. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46807. * from cos thetav and roughness:
  46808. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46809. */
  46810. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46811. /**
  46812. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46813. */
  46814. protected _forceIrradianceInFragment: boolean;
  46815. /**
  46816. * Force normal to face away from face.
  46817. */
  46818. protected _forceNormalForward: boolean;
  46819. /**
  46820. * Enables specular anti aliasing in the PBR shader.
  46821. * It will both interacts on the Geometry for analytical and IBL lighting.
  46822. * It also prefilter the roughness map based on the bump values.
  46823. */
  46824. protected _enableSpecularAntiAliasing: boolean;
  46825. /**
  46826. * Default configuration related to image processing available in the PBR Material.
  46827. */
  46828. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46829. /**
  46830. * Keep track of the image processing observer to allow dispose and replace.
  46831. */
  46832. private _imageProcessingObserver;
  46833. /**
  46834. * Attaches a new image processing configuration to the PBR Material.
  46835. * @param configuration
  46836. */
  46837. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46838. /**
  46839. * Stores the available render targets.
  46840. */
  46841. private _renderTargets;
  46842. /**
  46843. * Sets the global ambient color for the material used in lighting calculations.
  46844. */
  46845. private _globalAmbientColor;
  46846. /**
  46847. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46848. */
  46849. private _useLogarithmicDepth;
  46850. /**
  46851. * If set to true, no lighting calculations will be applied.
  46852. */
  46853. private _unlit;
  46854. private _debugMode;
  46855. /**
  46856. * @hidden
  46857. * This is reserved for the inspector.
  46858. * Defines the material debug mode.
  46859. * It helps seeing only some components of the material while troubleshooting.
  46860. */
  46861. debugMode: number;
  46862. /**
  46863. * @hidden
  46864. * This is reserved for the inspector.
  46865. * Specify from where on screen the debug mode should start.
  46866. * The value goes from -1 (full screen) to 1 (not visible)
  46867. * It helps with side by side comparison against the final render
  46868. * This defaults to -1
  46869. */
  46870. private debugLimit;
  46871. /**
  46872. * @hidden
  46873. * This is reserved for the inspector.
  46874. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46875. * You can use the factor to better multiply the final value.
  46876. */
  46877. private debugFactor;
  46878. /**
  46879. * Defines the clear coat layer parameters for the material.
  46880. */
  46881. readonly clearCoat: PBRClearCoatConfiguration;
  46882. /**
  46883. * Defines the anisotropic parameters for the material.
  46884. */
  46885. readonly anisotropy: PBRAnisotropicConfiguration;
  46886. /**
  46887. * Defines the BRDF parameters for the material.
  46888. */
  46889. readonly brdf: PBRBRDFConfiguration;
  46890. /**
  46891. * Defines the Sheen parameters for the material.
  46892. */
  46893. readonly sheen: PBRSheenConfiguration;
  46894. /**
  46895. * Defines the SubSurface parameters for the material.
  46896. */
  46897. readonly subSurface: PBRSubSurfaceConfiguration;
  46898. /**
  46899. * Custom callback helping to override the default shader used in the material.
  46900. */
  46901. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46902. protected _rebuildInParallel: boolean;
  46903. /**
  46904. * Instantiates a new PBRMaterial instance.
  46905. *
  46906. * @param name The material name
  46907. * @param scene The scene the material will be use in.
  46908. */
  46909. constructor(name: string, scene: Scene);
  46910. /**
  46911. * Gets a boolean indicating that current material needs to register RTT
  46912. */
  46913. readonly hasRenderTargetTextures: boolean;
  46914. /**
  46915. * Gets the name of the material class.
  46916. */
  46917. getClassName(): string;
  46918. /**
  46919. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46920. */
  46921. /**
  46922. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46923. */
  46924. useLogarithmicDepth: boolean;
  46925. /**
  46926. * Gets the current transparency mode.
  46927. */
  46928. /**
  46929. * Sets the transparency mode of the material.
  46930. *
  46931. * | Value | Type | Description |
  46932. * | ----- | ----------------------------------- | ----------- |
  46933. * | 0 | OPAQUE | |
  46934. * | 1 | ALPHATEST | |
  46935. * | 2 | ALPHABLEND | |
  46936. * | 3 | ALPHATESTANDBLEND | |
  46937. *
  46938. */
  46939. transparencyMode: Nullable<number>;
  46940. /**
  46941. * Returns true if alpha blending should be disabled.
  46942. */
  46943. private readonly _disableAlphaBlending;
  46944. /**
  46945. * Specifies whether or not this material should be rendered in alpha blend mode.
  46946. */
  46947. needAlphaBlending(): boolean;
  46948. /**
  46949. * Specifies if the mesh will require alpha blending.
  46950. * @param mesh - BJS mesh.
  46951. */
  46952. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46953. /**
  46954. * Specifies whether or not this material should be rendered in alpha test mode.
  46955. */
  46956. needAlphaTesting(): boolean;
  46957. /**
  46958. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46959. */
  46960. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46961. /**
  46962. * Gets the texture used for the alpha test.
  46963. */
  46964. getAlphaTestTexture(): Nullable<BaseTexture>;
  46965. /**
  46966. * Specifies that the submesh is ready to be used.
  46967. * @param mesh - BJS mesh.
  46968. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46969. * @param useInstances - Specifies that instances should be used.
  46970. * @returns - boolean indicating that the submesh is ready or not.
  46971. */
  46972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46973. /**
  46974. * Specifies if the material uses metallic roughness workflow.
  46975. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46976. */
  46977. isMetallicWorkflow(): boolean;
  46978. private _prepareEffect;
  46979. private _prepareDefines;
  46980. /**
  46981. * Force shader compilation
  46982. */
  46983. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46984. clipPlane: boolean;
  46985. }>): void;
  46986. /**
  46987. * Initializes the uniform buffer layout for the shader.
  46988. */
  46989. buildUniformLayout(): void;
  46990. /**
  46991. * Unbinds the material from the mesh
  46992. */
  46993. unbind(): void;
  46994. /**
  46995. * Binds the submesh data.
  46996. * @param world - The world matrix.
  46997. * @param mesh - The BJS mesh.
  46998. * @param subMesh - A submesh of the BJS mesh.
  46999. */
  47000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47001. /**
  47002. * Returns the animatable textures.
  47003. * @returns - Array of animatable textures.
  47004. */
  47005. getAnimatables(): IAnimatable[];
  47006. /**
  47007. * Returns the texture used for reflections.
  47008. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47009. */
  47010. private _getReflectionTexture;
  47011. /**
  47012. * Returns an array of the actively used textures.
  47013. * @returns - Array of BaseTextures
  47014. */
  47015. getActiveTextures(): BaseTexture[];
  47016. /**
  47017. * Checks to see if a texture is used in the material.
  47018. * @param texture - Base texture to use.
  47019. * @returns - Boolean specifying if a texture is used in the material.
  47020. */
  47021. hasTexture(texture: BaseTexture): boolean;
  47022. /**
  47023. * Disposes the resources of the material.
  47024. * @param forceDisposeEffect - Forces the disposal of effects.
  47025. * @param forceDisposeTextures - Forces the disposal of all textures.
  47026. */
  47027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47028. }
  47029. }
  47030. declare module BABYLON {
  47031. /**
  47032. * The Physically based material of BJS.
  47033. *
  47034. * This offers the main features of a standard PBR material.
  47035. * For more information, please refer to the documentation :
  47036. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47037. */
  47038. export class PBRMaterial extends PBRBaseMaterial {
  47039. /**
  47040. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47041. */
  47042. static readonly PBRMATERIAL_OPAQUE: number;
  47043. /**
  47044. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47045. */
  47046. static readonly PBRMATERIAL_ALPHATEST: number;
  47047. /**
  47048. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47049. */
  47050. static readonly PBRMATERIAL_ALPHABLEND: number;
  47051. /**
  47052. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47053. * They are also discarded below the alpha cutoff threshold to improve performances.
  47054. */
  47055. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47056. /**
  47057. * Defines the default value of how much AO map is occluding the analytical lights
  47058. * (point spot...).
  47059. */
  47060. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47061. /**
  47062. * Intensity of the direct lights e.g. the four lights available in your scene.
  47063. * This impacts both the direct diffuse and specular highlights.
  47064. */
  47065. directIntensity: number;
  47066. /**
  47067. * Intensity of the emissive part of the material.
  47068. * This helps controlling the emissive effect without modifying the emissive color.
  47069. */
  47070. emissiveIntensity: number;
  47071. /**
  47072. * Intensity of the environment e.g. how much the environment will light the object
  47073. * either through harmonics for rough material or through the refelction for shiny ones.
  47074. */
  47075. environmentIntensity: number;
  47076. /**
  47077. * This is a special control allowing the reduction of the specular highlights coming from the
  47078. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47079. */
  47080. specularIntensity: number;
  47081. /**
  47082. * Debug Control allowing disabling the bump map on this material.
  47083. */
  47084. disableBumpMap: boolean;
  47085. /**
  47086. * AKA Diffuse Texture in standard nomenclature.
  47087. */
  47088. albedoTexture: BaseTexture;
  47089. /**
  47090. * AKA Occlusion Texture in other nomenclature.
  47091. */
  47092. ambientTexture: BaseTexture;
  47093. /**
  47094. * AKA Occlusion Texture Intensity in other nomenclature.
  47095. */
  47096. ambientTextureStrength: number;
  47097. /**
  47098. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47099. * 1 means it completely occludes it
  47100. * 0 mean it has no impact
  47101. */
  47102. ambientTextureImpactOnAnalyticalLights: number;
  47103. /**
  47104. * Stores the alpha values in a texture.
  47105. */
  47106. opacityTexture: BaseTexture;
  47107. /**
  47108. * Stores the reflection values in a texture.
  47109. */
  47110. reflectionTexture: Nullable<BaseTexture>;
  47111. /**
  47112. * Stores the emissive values in a texture.
  47113. */
  47114. emissiveTexture: BaseTexture;
  47115. /**
  47116. * AKA Specular texture in other nomenclature.
  47117. */
  47118. reflectivityTexture: BaseTexture;
  47119. /**
  47120. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47121. */
  47122. metallicTexture: BaseTexture;
  47123. /**
  47124. * Specifies the metallic scalar of the metallic/roughness workflow.
  47125. * Can also be used to scale the metalness values of the metallic texture.
  47126. */
  47127. metallic: Nullable<number>;
  47128. /**
  47129. * Specifies the roughness scalar of the metallic/roughness workflow.
  47130. * Can also be used to scale the roughness values of the metallic texture.
  47131. */
  47132. roughness: Nullable<number>;
  47133. /**
  47134. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47135. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47136. */
  47137. microSurfaceTexture: BaseTexture;
  47138. /**
  47139. * Stores surface normal data used to displace a mesh in a texture.
  47140. */
  47141. bumpTexture: BaseTexture;
  47142. /**
  47143. * Stores the pre-calculated light information of a mesh in a texture.
  47144. */
  47145. lightmapTexture: BaseTexture;
  47146. /**
  47147. * Stores the refracted light information in a texture.
  47148. */
  47149. refractionTexture: Nullable<BaseTexture>;
  47150. /**
  47151. * The color of a material in ambient lighting.
  47152. */
  47153. ambientColor: Color3;
  47154. /**
  47155. * AKA Diffuse Color in other nomenclature.
  47156. */
  47157. albedoColor: Color3;
  47158. /**
  47159. * AKA Specular Color in other nomenclature.
  47160. */
  47161. reflectivityColor: Color3;
  47162. /**
  47163. * The color reflected from the material.
  47164. */
  47165. reflectionColor: Color3;
  47166. /**
  47167. * The color emitted from the material.
  47168. */
  47169. emissiveColor: Color3;
  47170. /**
  47171. * AKA Glossiness in other nomenclature.
  47172. */
  47173. microSurface: number;
  47174. /**
  47175. * source material index of refraction (IOR)' / 'destination material IOR.
  47176. */
  47177. indexOfRefraction: number;
  47178. /**
  47179. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47180. */
  47181. invertRefractionY: boolean;
  47182. /**
  47183. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47184. * Materials half opaque for instance using refraction could benefit from this control.
  47185. */
  47186. linkRefractionWithTransparency: boolean;
  47187. /**
  47188. * If true, the light map contains occlusion information instead of lighting info.
  47189. */
  47190. useLightmapAsShadowmap: boolean;
  47191. /**
  47192. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47193. */
  47194. useAlphaFromAlbedoTexture: boolean;
  47195. /**
  47196. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47197. */
  47198. forceAlphaTest: boolean;
  47199. /**
  47200. * Defines the alpha limits in alpha test mode.
  47201. */
  47202. alphaCutOff: number;
  47203. /**
  47204. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47205. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47206. */
  47207. useSpecularOverAlpha: boolean;
  47208. /**
  47209. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47210. */
  47211. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47212. /**
  47213. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47214. */
  47215. useRoughnessFromMetallicTextureAlpha: boolean;
  47216. /**
  47217. * Specifies if the metallic texture contains the roughness information in its green channel.
  47218. */
  47219. useRoughnessFromMetallicTextureGreen: boolean;
  47220. /**
  47221. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47222. */
  47223. useMetallnessFromMetallicTextureBlue: boolean;
  47224. /**
  47225. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47226. */
  47227. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47228. /**
  47229. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47230. */
  47231. useAmbientInGrayScale: boolean;
  47232. /**
  47233. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47234. * The material will try to infer what glossiness each pixel should be.
  47235. */
  47236. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47237. /**
  47238. * BJS is using an harcoded light falloff based on a manually sets up range.
  47239. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47240. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47241. */
  47242. /**
  47243. * BJS is using an harcoded light falloff based on a manually sets up range.
  47244. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47245. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47246. */
  47247. usePhysicalLightFalloff: boolean;
  47248. /**
  47249. * In order to support the falloff compatibility with gltf, a special mode has been added
  47250. * to reproduce the gltf light falloff.
  47251. */
  47252. /**
  47253. * In order to support the falloff compatibility with gltf, a special mode has been added
  47254. * to reproduce the gltf light falloff.
  47255. */
  47256. useGLTFLightFalloff: boolean;
  47257. /**
  47258. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47259. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47260. */
  47261. useRadianceOverAlpha: boolean;
  47262. /**
  47263. * Allows using an object space normal map (instead of tangent space).
  47264. */
  47265. useObjectSpaceNormalMap: boolean;
  47266. /**
  47267. * Allows using the bump map in parallax mode.
  47268. */
  47269. useParallax: boolean;
  47270. /**
  47271. * Allows using the bump map in parallax occlusion mode.
  47272. */
  47273. useParallaxOcclusion: boolean;
  47274. /**
  47275. * Controls the scale bias of the parallax mode.
  47276. */
  47277. parallaxScaleBias: number;
  47278. /**
  47279. * If sets to true, disables all the lights affecting the material.
  47280. */
  47281. disableLighting: boolean;
  47282. /**
  47283. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47284. */
  47285. forceIrradianceInFragment: boolean;
  47286. /**
  47287. * Number of Simultaneous lights allowed on the material.
  47288. */
  47289. maxSimultaneousLights: number;
  47290. /**
  47291. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47292. */
  47293. invertNormalMapX: boolean;
  47294. /**
  47295. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47296. */
  47297. invertNormalMapY: boolean;
  47298. /**
  47299. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47300. */
  47301. twoSidedLighting: boolean;
  47302. /**
  47303. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47304. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47305. */
  47306. useAlphaFresnel: boolean;
  47307. /**
  47308. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47309. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47310. */
  47311. useLinearAlphaFresnel: boolean;
  47312. /**
  47313. * Let user defines the brdf lookup texture used for IBL.
  47314. * A default 8bit version is embedded but you could point at :
  47315. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47316. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47317. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47318. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47319. */
  47320. environmentBRDFTexture: Nullable<BaseTexture>;
  47321. /**
  47322. * Force normal to face away from face.
  47323. */
  47324. forceNormalForward: boolean;
  47325. /**
  47326. * Enables specular anti aliasing in the PBR shader.
  47327. * It will both interacts on the Geometry for analytical and IBL lighting.
  47328. * It also prefilter the roughness map based on the bump values.
  47329. */
  47330. enableSpecularAntiAliasing: boolean;
  47331. /**
  47332. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47333. * makes the reflect vector face the model (under horizon).
  47334. */
  47335. useHorizonOcclusion: boolean;
  47336. /**
  47337. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47338. * too much the area relying on ambient texture to define their ambient occlusion.
  47339. */
  47340. useRadianceOcclusion: boolean;
  47341. /**
  47342. * If set to true, no lighting calculations will be applied.
  47343. */
  47344. unlit: boolean;
  47345. /**
  47346. * Gets the image processing configuration used either in this material.
  47347. */
  47348. /**
  47349. * Sets the Default image processing configuration used either in the this material.
  47350. *
  47351. * If sets to null, the scene one is in use.
  47352. */
  47353. imageProcessingConfiguration: ImageProcessingConfiguration;
  47354. /**
  47355. * Gets wether the color curves effect is enabled.
  47356. */
  47357. /**
  47358. * Sets wether the color curves effect is enabled.
  47359. */
  47360. cameraColorCurvesEnabled: boolean;
  47361. /**
  47362. * Gets wether the color grading effect is enabled.
  47363. */
  47364. /**
  47365. * Gets wether the color grading effect is enabled.
  47366. */
  47367. cameraColorGradingEnabled: boolean;
  47368. /**
  47369. * Gets wether tonemapping is enabled or not.
  47370. */
  47371. /**
  47372. * Sets wether tonemapping is enabled or not
  47373. */
  47374. cameraToneMappingEnabled: boolean;
  47375. /**
  47376. * The camera exposure used on this material.
  47377. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47378. * This corresponds to a photographic exposure.
  47379. */
  47380. /**
  47381. * The camera exposure used on this material.
  47382. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47383. * This corresponds to a photographic exposure.
  47384. */
  47385. cameraExposure: number;
  47386. /**
  47387. * Gets The camera contrast used on this material.
  47388. */
  47389. /**
  47390. * Sets The camera contrast used on this material.
  47391. */
  47392. cameraContrast: number;
  47393. /**
  47394. * Gets the Color Grading 2D Lookup Texture.
  47395. */
  47396. /**
  47397. * Sets the Color Grading 2D Lookup Texture.
  47398. */
  47399. cameraColorGradingTexture: Nullable<BaseTexture>;
  47400. /**
  47401. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47402. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47403. * 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;
  47404. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47405. */
  47406. /**
  47407. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47408. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47409. * 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;
  47410. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47411. */
  47412. cameraColorCurves: Nullable<ColorCurves>;
  47413. /**
  47414. * Instantiates a new PBRMaterial instance.
  47415. *
  47416. * @param name The material name
  47417. * @param scene The scene the material will be use in.
  47418. */
  47419. constructor(name: string, scene: Scene);
  47420. /**
  47421. * Returns the name of this material class.
  47422. */
  47423. getClassName(): string;
  47424. /**
  47425. * Makes a duplicate of the current material.
  47426. * @param name - name to use for the new material.
  47427. */
  47428. clone(name: string): PBRMaterial;
  47429. /**
  47430. * Serializes this PBR Material.
  47431. * @returns - An object with the serialized material.
  47432. */
  47433. serialize(): any;
  47434. /**
  47435. * Parses a PBR Material from a serialized object.
  47436. * @param source - Serialized object.
  47437. * @param scene - BJS scene instance.
  47438. * @param rootUrl - url for the scene object
  47439. * @returns - PBRMaterial
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47442. }
  47443. }
  47444. declare module BABYLON {
  47445. /**
  47446. * Direct draw surface info
  47447. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47448. */
  47449. export interface DDSInfo {
  47450. /**
  47451. * Width of the texture
  47452. */
  47453. width: number;
  47454. /**
  47455. * Width of the texture
  47456. */
  47457. height: number;
  47458. /**
  47459. * Number of Mipmaps for the texture
  47460. * @see https://en.wikipedia.org/wiki/Mipmap
  47461. */
  47462. mipmapCount: number;
  47463. /**
  47464. * If the textures format is a known fourCC format
  47465. * @see https://www.fourcc.org/
  47466. */
  47467. isFourCC: boolean;
  47468. /**
  47469. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47470. */
  47471. isRGB: boolean;
  47472. /**
  47473. * If the texture is a lumincance format
  47474. */
  47475. isLuminance: boolean;
  47476. /**
  47477. * If this is a cube texture
  47478. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47479. */
  47480. isCube: boolean;
  47481. /**
  47482. * If the texture is a compressed format eg. FOURCC_DXT1
  47483. */
  47484. isCompressed: boolean;
  47485. /**
  47486. * The dxgiFormat of the texture
  47487. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47488. */
  47489. dxgiFormat: number;
  47490. /**
  47491. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47492. */
  47493. textureType: number;
  47494. /**
  47495. * Sphericle polynomial created for the dds texture
  47496. */
  47497. sphericalPolynomial?: SphericalPolynomial;
  47498. }
  47499. /**
  47500. * Class used to provide DDS decompression tools
  47501. */
  47502. export class DDSTools {
  47503. /**
  47504. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47505. */
  47506. static StoreLODInAlphaChannel: boolean;
  47507. /**
  47508. * Gets DDS information from an array buffer
  47509. * @param arrayBuffer defines the array buffer to read data from
  47510. * @returns the DDS information
  47511. */
  47512. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47513. private static _FloatView;
  47514. private static _Int32View;
  47515. private static _ToHalfFloat;
  47516. private static _FromHalfFloat;
  47517. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47518. private static _GetHalfFloatRGBAArrayBuffer;
  47519. private static _GetFloatRGBAArrayBuffer;
  47520. private static _GetFloatAsUIntRGBAArrayBuffer;
  47521. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47522. private static _GetRGBAArrayBuffer;
  47523. private static _ExtractLongWordOrder;
  47524. private static _GetRGBArrayBuffer;
  47525. private static _GetLuminanceArrayBuffer;
  47526. /**
  47527. * Uploads DDS Levels to a Babylon Texture
  47528. * @hidden
  47529. */
  47530. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47531. }
  47532. interface Engine {
  47533. /**
  47534. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47535. * @param rootUrl defines the url where the file to load is located
  47536. * @param scene defines the current scene
  47537. * @param lodScale defines scale to apply to the mip map selection
  47538. * @param lodOffset defines offset to apply to the mip map selection
  47539. * @param onLoad defines an optional callback raised when the texture is loaded
  47540. * @param onError defines an optional callback raised if there is an issue to load the texture
  47541. * @param format defines the format of the data
  47542. * @param forcedExtension defines the extension to use to pick the right loader
  47543. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47544. * @returns the cube texture as an InternalTexture
  47545. */
  47546. 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;
  47547. }
  47548. }
  47549. declare module BABYLON {
  47550. /**
  47551. * Implementation of the DDS Texture Loader.
  47552. * @hidden
  47553. */
  47554. export class _DDSTextureLoader implements IInternalTextureLoader {
  47555. /**
  47556. * Defines wether the loader supports cascade loading the different faces.
  47557. */
  47558. readonly supportCascades: boolean;
  47559. /**
  47560. * This returns if the loader support the current file information.
  47561. * @param extension defines the file extension of the file being loaded
  47562. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47563. * @param fallback defines the fallback internal texture if any
  47564. * @param isBase64 defines whether the texture is encoded as a base64
  47565. * @param isBuffer defines whether the texture data are stored as a buffer
  47566. * @returns true if the loader can load the specified file
  47567. */
  47568. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47569. /**
  47570. * Transform the url before loading if required.
  47571. * @param rootUrl the url of the texture
  47572. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47573. * @returns the transformed texture
  47574. */
  47575. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47576. /**
  47577. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47578. * @param rootUrl the url of the texture
  47579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47580. * @returns the fallback texture
  47581. */
  47582. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47583. /**
  47584. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47585. * @param data contains the texture data
  47586. * @param texture defines the BabylonJS internal texture
  47587. * @param createPolynomials will be true if polynomials have been requested
  47588. * @param onLoad defines the callback to trigger once the texture is ready
  47589. * @param onError defines the callback to trigger in case of error
  47590. */
  47591. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47592. /**
  47593. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47594. * @param data contains the texture data
  47595. * @param texture defines the BabylonJS internal texture
  47596. * @param callback defines the method to call once ready to upload
  47597. */
  47598. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47599. }
  47600. }
  47601. declare module BABYLON {
  47602. /** @hidden */
  47603. export var rgbdEncodePixelShader: {
  47604. name: string;
  47605. shader: string;
  47606. };
  47607. }
  47608. declare module BABYLON {
  47609. /**
  47610. * Raw texture data and descriptor sufficient for WebGL texture upload
  47611. */
  47612. export interface EnvironmentTextureInfo {
  47613. /**
  47614. * Version of the environment map
  47615. */
  47616. version: number;
  47617. /**
  47618. * Width of image
  47619. */
  47620. width: number;
  47621. /**
  47622. * Irradiance information stored in the file.
  47623. */
  47624. irradiance: any;
  47625. /**
  47626. * Specular information stored in the file.
  47627. */
  47628. specular: any;
  47629. }
  47630. /**
  47631. * Sets of helpers addressing the serialization and deserialization of environment texture
  47632. * stored in a BabylonJS env file.
  47633. * Those files are usually stored as .env files.
  47634. */
  47635. export class EnvironmentTextureTools {
  47636. /**
  47637. * Magic number identifying the env file.
  47638. */
  47639. private static _MagicBytes;
  47640. /**
  47641. * Gets the environment info from an env file.
  47642. * @param data The array buffer containing the .env bytes.
  47643. * @returns the environment file info (the json header) if successfully parsed.
  47644. */
  47645. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47646. /**
  47647. * Creates an environment texture from a loaded cube texture.
  47648. * @param texture defines the cube texture to convert in env file
  47649. * @return a promise containing the environment data if succesfull.
  47650. */
  47651. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47652. /**
  47653. * Creates a JSON representation of the spherical data.
  47654. * @param texture defines the texture containing the polynomials
  47655. * @return the JSON representation of the spherical info
  47656. */
  47657. private static _CreateEnvTextureIrradiance;
  47658. /**
  47659. * Uploads the texture info contained in the env file to the GPU.
  47660. * @param texture defines the internal texture to upload to
  47661. * @param arrayBuffer defines the buffer cotaining the data to load
  47662. * @param info defines the texture info retrieved through the GetEnvInfo method
  47663. * @returns a promise
  47664. */
  47665. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47666. /**
  47667. * Uploads the levels of image data to the GPU.
  47668. * @param texture defines the internal texture to upload to
  47669. * @param imageData defines the array buffer views of image data [mipmap][face]
  47670. * @returns a promise
  47671. */
  47672. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47673. /**
  47674. * Uploads spherical polynomials information to the texture.
  47675. * @param texture defines the texture we are trying to upload the information to
  47676. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47677. */
  47678. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47679. /** @hidden */
  47680. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47681. }
  47682. }
  47683. declare module BABYLON {
  47684. /**
  47685. * Implementation of the ENV Texture Loader.
  47686. * @hidden
  47687. */
  47688. export class _ENVTextureLoader implements IInternalTextureLoader {
  47689. /**
  47690. * Defines wether the loader supports cascade loading the different faces.
  47691. */
  47692. readonly supportCascades: boolean;
  47693. /**
  47694. * This returns if the loader support the current file information.
  47695. * @param extension defines the file extension of the file being loaded
  47696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47697. * @param fallback defines the fallback internal texture if any
  47698. * @param isBase64 defines whether the texture is encoded as a base64
  47699. * @param isBuffer defines whether the texture data are stored as a buffer
  47700. * @returns true if the loader can load the specified file
  47701. */
  47702. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47703. /**
  47704. * Transform the url before loading if required.
  47705. * @param rootUrl the url of the texture
  47706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47707. * @returns the transformed texture
  47708. */
  47709. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47710. /**
  47711. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47712. * @param rootUrl the url of the texture
  47713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47714. * @returns the fallback texture
  47715. */
  47716. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47717. /**
  47718. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47719. * @param data contains the texture data
  47720. * @param texture defines the BabylonJS internal texture
  47721. * @param createPolynomials will be true if polynomials have been requested
  47722. * @param onLoad defines the callback to trigger once the texture is ready
  47723. * @param onError defines the callback to trigger in case of error
  47724. */
  47725. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47726. /**
  47727. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47728. * @param data contains the texture data
  47729. * @param texture defines the BabylonJS internal texture
  47730. * @param callback defines the method to call once ready to upload
  47731. */
  47732. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47733. }
  47734. }
  47735. declare module BABYLON {
  47736. /**
  47737. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47738. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47739. */
  47740. export class KhronosTextureContainer {
  47741. /** contents of the KTX container file */
  47742. arrayBuffer: any;
  47743. private static HEADER_LEN;
  47744. private static COMPRESSED_2D;
  47745. private static COMPRESSED_3D;
  47746. private static TEX_2D;
  47747. private static TEX_3D;
  47748. /**
  47749. * Gets the openGL type
  47750. */
  47751. glType: number;
  47752. /**
  47753. * Gets the openGL type size
  47754. */
  47755. glTypeSize: number;
  47756. /**
  47757. * Gets the openGL format
  47758. */
  47759. glFormat: number;
  47760. /**
  47761. * Gets the openGL internal format
  47762. */
  47763. glInternalFormat: number;
  47764. /**
  47765. * Gets the base internal format
  47766. */
  47767. glBaseInternalFormat: number;
  47768. /**
  47769. * Gets image width in pixel
  47770. */
  47771. pixelWidth: number;
  47772. /**
  47773. * Gets image height in pixel
  47774. */
  47775. pixelHeight: number;
  47776. /**
  47777. * Gets image depth in pixels
  47778. */
  47779. pixelDepth: number;
  47780. /**
  47781. * Gets the number of array elements
  47782. */
  47783. numberOfArrayElements: number;
  47784. /**
  47785. * Gets the number of faces
  47786. */
  47787. numberOfFaces: number;
  47788. /**
  47789. * Gets the number of mipmap levels
  47790. */
  47791. numberOfMipmapLevels: number;
  47792. /**
  47793. * Gets the bytes of key value data
  47794. */
  47795. bytesOfKeyValueData: number;
  47796. /**
  47797. * Gets the load type
  47798. */
  47799. loadType: number;
  47800. /**
  47801. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47802. */
  47803. isInvalid: boolean;
  47804. /**
  47805. * Creates a new KhronosTextureContainer
  47806. * @param arrayBuffer contents of the KTX container file
  47807. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47808. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47809. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47810. */
  47811. constructor(
  47812. /** contents of the KTX container file */
  47813. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47814. /**
  47815. * Uploads KTX content to a Babylon Texture.
  47816. * It is assumed that the texture has already been created & is currently bound
  47817. * @hidden
  47818. */
  47819. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47820. private _upload2DCompressedLevels;
  47821. }
  47822. }
  47823. declare module BABYLON {
  47824. /**
  47825. * Implementation of the KTX Texture Loader.
  47826. * @hidden
  47827. */
  47828. export class _KTXTextureLoader implements IInternalTextureLoader {
  47829. /**
  47830. * Defines wether the loader supports cascade loading the different faces.
  47831. */
  47832. readonly supportCascades: boolean;
  47833. /**
  47834. * This returns if the loader support the current file information.
  47835. * @param extension defines the file extension of the file being loaded
  47836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47837. * @param fallback defines the fallback internal texture if any
  47838. * @param isBase64 defines whether the texture is encoded as a base64
  47839. * @param isBuffer defines whether the texture data are stored as a buffer
  47840. * @returns true if the loader can load the specified file
  47841. */
  47842. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47843. /**
  47844. * Transform the url before loading if required.
  47845. * @param rootUrl the url of the texture
  47846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47847. * @returns the transformed texture
  47848. */
  47849. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47850. /**
  47851. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47852. * @param rootUrl the url of the texture
  47853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47854. * @returns the fallback texture
  47855. */
  47856. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47857. /**
  47858. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47859. * @param data contains the texture data
  47860. * @param texture defines the BabylonJS internal texture
  47861. * @param createPolynomials will be true if polynomials have been requested
  47862. * @param onLoad defines the callback to trigger once the texture is ready
  47863. * @param onError defines the callback to trigger in case of error
  47864. */
  47865. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47866. /**
  47867. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47868. * @param data contains the texture data
  47869. * @param texture defines the BabylonJS internal texture
  47870. * @param callback defines the method to call once ready to upload
  47871. */
  47872. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. /**
  47877. * Options for the default xr helper
  47878. */
  47879. export class WebXRDefaultExperienceOptions {
  47880. /**
  47881. * Floor meshes that should be used for teleporting
  47882. */
  47883. floorMeshes: Array<AbstractMesh>;
  47884. }
  47885. /**
  47886. * Default experience which provides a similar setup to the previous webVRExperience
  47887. */
  47888. export class WebXRDefaultExperience {
  47889. /**
  47890. * Base experience
  47891. */
  47892. baseExperience: WebXRExperienceHelper;
  47893. /**
  47894. * Input experience extension
  47895. */
  47896. input: WebXRInput;
  47897. /**
  47898. * Loads the controller models
  47899. */
  47900. controllerModelLoader: WebXRControllerModelLoader;
  47901. /**
  47902. * Enables laser pointer and selection
  47903. */
  47904. pointerSelection: WebXRControllerPointerSelection;
  47905. /**
  47906. * Enables teleportation
  47907. */
  47908. teleportation: WebXRControllerTeleportation;
  47909. /**
  47910. * Enables ui for enetering/exiting xr
  47911. */
  47912. enterExitUI: WebXREnterExitUI;
  47913. /**
  47914. * Default output canvas xr should render to
  47915. */
  47916. outputCanvas: WebXRManagedOutputCanvas;
  47917. /**
  47918. * Creates the default xr experience
  47919. * @param scene scene
  47920. * @param options options for basic configuration
  47921. * @returns resulting WebXRDefaultExperience
  47922. */
  47923. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47924. private constructor();
  47925. /**
  47926. * DIsposes of the experience helper
  47927. */
  47928. dispose(): void;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /** @hidden */
  47933. export var _forceSceneHelpersToBundle: boolean;
  47934. interface Scene {
  47935. /**
  47936. * Creates a default light for the scene.
  47937. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47938. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47939. */
  47940. createDefaultLight(replace?: boolean): void;
  47941. /**
  47942. * Creates a default camera for the scene.
  47943. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47944. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47945. * @param replace has default false, when true replaces the active camera in the scene
  47946. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47947. */
  47948. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47949. /**
  47950. * Creates a default camera and a default light.
  47951. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47952. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47953. * @param replace has the default false, when true replaces the active camera/light in the scene
  47954. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47955. */
  47956. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47957. /**
  47958. * Creates a new sky box
  47959. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47960. * @param environmentTexture defines the texture to use as environment texture
  47961. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47962. * @param scale defines the overall scale of the skybox
  47963. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47964. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47965. * @returns a new mesh holding the sky box
  47966. */
  47967. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47968. /**
  47969. * Creates a new environment
  47970. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47971. * @param options defines the options you can use to configure the environment
  47972. * @returns the new EnvironmentHelper
  47973. */
  47974. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47975. /**
  47976. * Creates a new VREXperienceHelper
  47977. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47978. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47979. * @returns a new VREXperienceHelper
  47980. */
  47981. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47982. /**
  47983. * Creates a new WebXRDefaultExperience
  47984. * @see http://doc.babylonjs.com/how_to/webxr
  47985. * @param options experience options
  47986. * @returns a promise for a new WebXRDefaultExperience
  47987. */
  47988. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47989. }
  47990. }
  47991. declare module BABYLON {
  47992. /**
  47993. * Contains position and normal vectors for a vertex
  47994. */
  47995. export class PositionNormalVertex {
  47996. /** the position of the vertex (defaut: 0,0,0) */
  47997. position: Vector3;
  47998. /** the normal of the vertex (defaut: 0,1,0) */
  47999. normal: Vector3;
  48000. /**
  48001. * Creates a PositionNormalVertex
  48002. * @param position the position of the vertex (defaut: 0,0,0)
  48003. * @param normal the normal of the vertex (defaut: 0,1,0)
  48004. */
  48005. constructor(
  48006. /** the position of the vertex (defaut: 0,0,0) */
  48007. position?: Vector3,
  48008. /** the normal of the vertex (defaut: 0,1,0) */
  48009. normal?: Vector3);
  48010. /**
  48011. * Clones the PositionNormalVertex
  48012. * @returns the cloned PositionNormalVertex
  48013. */
  48014. clone(): PositionNormalVertex;
  48015. }
  48016. /**
  48017. * Contains position, normal and uv vectors for a vertex
  48018. */
  48019. export class PositionNormalTextureVertex {
  48020. /** the position of the vertex (defaut: 0,0,0) */
  48021. position: Vector3;
  48022. /** the normal of the vertex (defaut: 0,1,0) */
  48023. normal: Vector3;
  48024. /** the uv of the vertex (default: 0,0) */
  48025. uv: Vector2;
  48026. /**
  48027. * Creates a PositionNormalTextureVertex
  48028. * @param position the position of the vertex (defaut: 0,0,0)
  48029. * @param normal the normal of the vertex (defaut: 0,1,0)
  48030. * @param uv the uv of the vertex (default: 0,0)
  48031. */
  48032. constructor(
  48033. /** the position of the vertex (defaut: 0,0,0) */
  48034. position?: Vector3,
  48035. /** the normal of the vertex (defaut: 0,1,0) */
  48036. normal?: Vector3,
  48037. /** the uv of the vertex (default: 0,0) */
  48038. uv?: Vector2);
  48039. /**
  48040. * Clones the PositionNormalTextureVertex
  48041. * @returns the cloned PositionNormalTextureVertex
  48042. */
  48043. clone(): PositionNormalTextureVertex;
  48044. }
  48045. }
  48046. declare module BABYLON {
  48047. /**
  48048. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48049. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48050. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48051. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48052. */
  48053. export class VideoDome extends TransformNode {
  48054. /**
  48055. * Define the video source as a Monoscopic panoramic 360 video.
  48056. */
  48057. static readonly MODE_MONOSCOPIC: number;
  48058. /**
  48059. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48060. */
  48061. static readonly MODE_TOPBOTTOM: number;
  48062. /**
  48063. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48064. */
  48065. static readonly MODE_SIDEBYSIDE: number;
  48066. private _halfDome;
  48067. private _useDirectMapping;
  48068. /**
  48069. * The video texture being displayed on the sphere
  48070. */
  48071. protected _videoTexture: VideoTexture;
  48072. /**
  48073. * Gets the video texture being displayed on the sphere
  48074. */
  48075. readonly videoTexture: VideoTexture;
  48076. /**
  48077. * The skybox material
  48078. */
  48079. protected _material: BackgroundMaterial;
  48080. /**
  48081. * The surface used for the skybox
  48082. */
  48083. protected _mesh: Mesh;
  48084. /**
  48085. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48086. */
  48087. private _halfDomeMask;
  48088. /**
  48089. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48090. * Also see the options.resolution property.
  48091. */
  48092. fovMultiplier: number;
  48093. private _videoMode;
  48094. /**
  48095. * Gets or set the current video mode for the video. It can be:
  48096. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48097. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48098. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48099. */
  48100. videoMode: number;
  48101. /**
  48102. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48103. *
  48104. */
  48105. /**
  48106. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48107. */
  48108. halfDome: boolean;
  48109. /**
  48110. * Oberserver used in Stereoscopic VR Mode.
  48111. */
  48112. private _onBeforeCameraRenderObserver;
  48113. /**
  48114. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48115. * @param name Element's name, child elements will append suffixes for their own names.
  48116. * @param urlsOrVideo defines the url(s) or the video element to use
  48117. * @param options An object containing optional or exposed sub element properties
  48118. */
  48119. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48120. resolution?: number;
  48121. clickToPlay?: boolean;
  48122. autoPlay?: boolean;
  48123. loop?: boolean;
  48124. size?: number;
  48125. poster?: string;
  48126. faceForward?: boolean;
  48127. useDirectMapping?: boolean;
  48128. halfDomeMode?: boolean;
  48129. }, scene: Scene);
  48130. private _changeVideoMode;
  48131. /**
  48132. * Releases resources associated with this node.
  48133. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48134. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48135. */
  48136. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48137. }
  48138. }
  48139. declare module BABYLON {
  48140. /**
  48141. * This class can be used to get instrumentation data from a Babylon engine
  48142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48143. */
  48144. export class EngineInstrumentation implements IDisposable {
  48145. /**
  48146. * Define the instrumented engine.
  48147. */
  48148. engine: Engine;
  48149. private _captureGPUFrameTime;
  48150. private _gpuFrameTimeToken;
  48151. private _gpuFrameTime;
  48152. private _captureShaderCompilationTime;
  48153. private _shaderCompilationTime;
  48154. private _onBeginFrameObserver;
  48155. private _onEndFrameObserver;
  48156. private _onBeforeShaderCompilationObserver;
  48157. private _onAfterShaderCompilationObserver;
  48158. /**
  48159. * Gets the perf counter used for GPU frame time
  48160. */
  48161. readonly gpuFrameTimeCounter: PerfCounter;
  48162. /**
  48163. * Gets the GPU frame time capture status
  48164. */
  48165. /**
  48166. * Enable or disable the GPU frame time capture
  48167. */
  48168. captureGPUFrameTime: boolean;
  48169. /**
  48170. * Gets the perf counter used for shader compilation time
  48171. */
  48172. readonly shaderCompilationTimeCounter: PerfCounter;
  48173. /**
  48174. * Gets the shader compilation time capture status
  48175. */
  48176. /**
  48177. * Enable or disable the shader compilation time capture
  48178. */
  48179. captureShaderCompilationTime: boolean;
  48180. /**
  48181. * Instantiates a new engine instrumentation.
  48182. * This class can be used to get instrumentation data from a Babylon engine
  48183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48184. * @param engine Defines the engine to instrument
  48185. */
  48186. constructor(
  48187. /**
  48188. * Define the instrumented engine.
  48189. */
  48190. engine: Engine);
  48191. /**
  48192. * Dispose and release associated resources.
  48193. */
  48194. dispose(): void;
  48195. }
  48196. }
  48197. declare module BABYLON {
  48198. /**
  48199. * This class can be used to get instrumentation data from a Babylon engine
  48200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48201. */
  48202. export class SceneInstrumentation implements IDisposable {
  48203. /**
  48204. * Defines the scene to instrument
  48205. */
  48206. scene: Scene;
  48207. private _captureActiveMeshesEvaluationTime;
  48208. private _activeMeshesEvaluationTime;
  48209. private _captureRenderTargetsRenderTime;
  48210. private _renderTargetsRenderTime;
  48211. private _captureFrameTime;
  48212. private _frameTime;
  48213. private _captureRenderTime;
  48214. private _renderTime;
  48215. private _captureInterFrameTime;
  48216. private _interFrameTime;
  48217. private _captureParticlesRenderTime;
  48218. private _particlesRenderTime;
  48219. private _captureSpritesRenderTime;
  48220. private _spritesRenderTime;
  48221. private _capturePhysicsTime;
  48222. private _physicsTime;
  48223. private _captureAnimationsTime;
  48224. private _animationsTime;
  48225. private _captureCameraRenderTime;
  48226. private _cameraRenderTime;
  48227. private _onBeforeActiveMeshesEvaluationObserver;
  48228. private _onAfterActiveMeshesEvaluationObserver;
  48229. private _onBeforeRenderTargetsRenderObserver;
  48230. private _onAfterRenderTargetsRenderObserver;
  48231. private _onAfterRenderObserver;
  48232. private _onBeforeDrawPhaseObserver;
  48233. private _onAfterDrawPhaseObserver;
  48234. private _onBeforeAnimationsObserver;
  48235. private _onBeforeParticlesRenderingObserver;
  48236. private _onAfterParticlesRenderingObserver;
  48237. private _onBeforeSpritesRenderingObserver;
  48238. private _onAfterSpritesRenderingObserver;
  48239. private _onBeforePhysicsObserver;
  48240. private _onAfterPhysicsObserver;
  48241. private _onAfterAnimationsObserver;
  48242. private _onBeforeCameraRenderObserver;
  48243. private _onAfterCameraRenderObserver;
  48244. /**
  48245. * Gets the perf counter used for active meshes evaluation time
  48246. */
  48247. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48248. /**
  48249. * Gets the active meshes evaluation time capture status
  48250. */
  48251. /**
  48252. * Enable or disable the active meshes evaluation time capture
  48253. */
  48254. captureActiveMeshesEvaluationTime: boolean;
  48255. /**
  48256. * Gets the perf counter used for render targets render time
  48257. */
  48258. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48259. /**
  48260. * Gets the render targets render time capture status
  48261. */
  48262. /**
  48263. * Enable or disable the render targets render time capture
  48264. */
  48265. captureRenderTargetsRenderTime: boolean;
  48266. /**
  48267. * Gets the perf counter used for particles render time
  48268. */
  48269. readonly particlesRenderTimeCounter: PerfCounter;
  48270. /**
  48271. * Gets the particles render time capture status
  48272. */
  48273. /**
  48274. * Enable or disable the particles render time capture
  48275. */
  48276. captureParticlesRenderTime: boolean;
  48277. /**
  48278. * Gets the perf counter used for sprites render time
  48279. */
  48280. readonly spritesRenderTimeCounter: PerfCounter;
  48281. /**
  48282. * Gets the sprites render time capture status
  48283. */
  48284. /**
  48285. * Enable or disable the sprites render time capture
  48286. */
  48287. captureSpritesRenderTime: boolean;
  48288. /**
  48289. * Gets the perf counter used for physics time
  48290. */
  48291. readonly physicsTimeCounter: PerfCounter;
  48292. /**
  48293. * Gets the physics time capture status
  48294. */
  48295. /**
  48296. * Enable or disable the physics time capture
  48297. */
  48298. capturePhysicsTime: boolean;
  48299. /**
  48300. * Gets the perf counter used for animations time
  48301. */
  48302. readonly animationsTimeCounter: PerfCounter;
  48303. /**
  48304. * Gets the animations time capture status
  48305. */
  48306. /**
  48307. * Enable or disable the animations time capture
  48308. */
  48309. captureAnimationsTime: boolean;
  48310. /**
  48311. * Gets the perf counter used for frame time capture
  48312. */
  48313. readonly frameTimeCounter: PerfCounter;
  48314. /**
  48315. * Gets the frame time capture status
  48316. */
  48317. /**
  48318. * Enable or disable the frame time capture
  48319. */
  48320. captureFrameTime: boolean;
  48321. /**
  48322. * Gets the perf counter used for inter-frames time capture
  48323. */
  48324. readonly interFrameTimeCounter: PerfCounter;
  48325. /**
  48326. * Gets the inter-frames time capture status
  48327. */
  48328. /**
  48329. * Enable or disable the inter-frames time capture
  48330. */
  48331. captureInterFrameTime: boolean;
  48332. /**
  48333. * Gets the perf counter used for render time capture
  48334. */
  48335. readonly renderTimeCounter: PerfCounter;
  48336. /**
  48337. * Gets the render time capture status
  48338. */
  48339. /**
  48340. * Enable or disable the render time capture
  48341. */
  48342. captureRenderTime: boolean;
  48343. /**
  48344. * Gets the perf counter used for camera render time capture
  48345. */
  48346. readonly cameraRenderTimeCounter: PerfCounter;
  48347. /**
  48348. * Gets the camera render time capture status
  48349. */
  48350. /**
  48351. * Enable or disable the camera render time capture
  48352. */
  48353. captureCameraRenderTime: boolean;
  48354. /**
  48355. * Gets the perf counter used for draw calls
  48356. */
  48357. readonly drawCallsCounter: PerfCounter;
  48358. /**
  48359. * Instantiates a new scene instrumentation.
  48360. * This class can be used to get instrumentation data from a Babylon engine
  48361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48362. * @param scene Defines the scene to instrument
  48363. */
  48364. constructor(
  48365. /**
  48366. * Defines the scene to instrument
  48367. */
  48368. scene: Scene);
  48369. /**
  48370. * Dispose and release associated resources.
  48371. */
  48372. dispose(): void;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /** @hidden */
  48377. export var glowMapGenerationPixelShader: {
  48378. name: string;
  48379. shader: string;
  48380. };
  48381. }
  48382. declare module BABYLON {
  48383. /** @hidden */
  48384. export var glowMapGenerationVertexShader: {
  48385. name: string;
  48386. shader: string;
  48387. };
  48388. }
  48389. declare module BABYLON {
  48390. /**
  48391. * Effect layer options. This helps customizing the behaviour
  48392. * of the effect layer.
  48393. */
  48394. export interface IEffectLayerOptions {
  48395. /**
  48396. * Multiplication factor apply to the canvas size to compute the render target size
  48397. * used to generated the objects (the smaller the faster).
  48398. */
  48399. mainTextureRatio: number;
  48400. /**
  48401. * Enforces a fixed size texture to ensure effect stability across devices.
  48402. */
  48403. mainTextureFixedSize?: number;
  48404. /**
  48405. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48406. */
  48407. alphaBlendingMode: number;
  48408. /**
  48409. * The camera attached to the layer.
  48410. */
  48411. camera: Nullable<Camera>;
  48412. /**
  48413. * The rendering group to draw the layer in.
  48414. */
  48415. renderingGroupId: number;
  48416. }
  48417. /**
  48418. * The effect layer Helps adding post process effect blended with the main pass.
  48419. *
  48420. * This can be for instance use to generate glow or higlight effects on the scene.
  48421. *
  48422. * The effect layer class can not be used directly and is intented to inherited from to be
  48423. * customized per effects.
  48424. */
  48425. export abstract class EffectLayer {
  48426. private _vertexBuffers;
  48427. private _indexBuffer;
  48428. private _cachedDefines;
  48429. private _effectLayerMapGenerationEffect;
  48430. private _effectLayerOptions;
  48431. private _mergeEffect;
  48432. protected _scene: Scene;
  48433. protected _engine: Engine;
  48434. protected _maxSize: number;
  48435. protected _mainTextureDesiredSize: ISize;
  48436. protected _mainTexture: RenderTargetTexture;
  48437. protected _shouldRender: boolean;
  48438. protected _postProcesses: PostProcess[];
  48439. protected _textures: BaseTexture[];
  48440. protected _emissiveTextureAndColor: {
  48441. texture: Nullable<BaseTexture>;
  48442. color: Color4;
  48443. };
  48444. /**
  48445. * The name of the layer
  48446. */
  48447. name: string;
  48448. /**
  48449. * The clear color of the texture used to generate the glow map.
  48450. */
  48451. neutralColor: Color4;
  48452. /**
  48453. * Specifies wether the highlight layer is enabled or not.
  48454. */
  48455. isEnabled: boolean;
  48456. /**
  48457. * Gets the camera attached to the layer.
  48458. */
  48459. readonly camera: Nullable<Camera>;
  48460. /**
  48461. * Gets the rendering group id the layer should render in.
  48462. */
  48463. renderingGroupId: number;
  48464. /**
  48465. * An event triggered when the effect layer has been disposed.
  48466. */
  48467. onDisposeObservable: Observable<EffectLayer>;
  48468. /**
  48469. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48470. */
  48471. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48472. /**
  48473. * An event triggered when the generated texture is being merged in the scene.
  48474. */
  48475. onBeforeComposeObservable: Observable<EffectLayer>;
  48476. /**
  48477. * An event triggered when the generated texture has been merged in the scene.
  48478. */
  48479. onAfterComposeObservable: Observable<EffectLayer>;
  48480. /**
  48481. * An event triggered when the efffect layer changes its size.
  48482. */
  48483. onSizeChangedObservable: Observable<EffectLayer>;
  48484. /** @hidden */
  48485. static _SceneComponentInitialization: (scene: Scene) => void;
  48486. /**
  48487. * Instantiates a new effect Layer and references it in the scene.
  48488. * @param name The name of the layer
  48489. * @param scene The scene to use the layer in
  48490. */
  48491. constructor(
  48492. /** The Friendly of the effect in the scene */
  48493. name: string, scene: Scene);
  48494. /**
  48495. * Get the effect name of the layer.
  48496. * @return The effect name
  48497. */
  48498. abstract getEffectName(): string;
  48499. /**
  48500. * Checks for the readiness of the element composing the layer.
  48501. * @param subMesh the mesh to check for
  48502. * @param useInstances specify wether or not to use instances to render the mesh
  48503. * @return true if ready otherwise, false
  48504. */
  48505. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48506. /**
  48507. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48508. * @returns true if the effect requires stencil during the main canvas render pass.
  48509. */
  48510. abstract needStencil(): boolean;
  48511. /**
  48512. * Create the merge effect. This is the shader use to blit the information back
  48513. * to the main canvas at the end of the scene rendering.
  48514. * @returns The effect containing the shader used to merge the effect on the main canvas
  48515. */
  48516. protected abstract _createMergeEffect(): Effect;
  48517. /**
  48518. * Creates the render target textures and post processes used in the effect layer.
  48519. */
  48520. protected abstract _createTextureAndPostProcesses(): void;
  48521. /**
  48522. * Implementation specific of rendering the generating effect on the main canvas.
  48523. * @param effect The effect used to render through
  48524. */
  48525. protected abstract _internalRender(effect: Effect): void;
  48526. /**
  48527. * Sets the required values for both the emissive texture and and the main color.
  48528. */
  48529. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48530. /**
  48531. * Free any resources and references associated to a mesh.
  48532. * Internal use
  48533. * @param mesh The mesh to free.
  48534. */
  48535. abstract _disposeMesh(mesh: Mesh): void;
  48536. /**
  48537. * Serializes this layer (Glow or Highlight for example)
  48538. * @returns a serialized layer object
  48539. */
  48540. abstract serialize?(): any;
  48541. /**
  48542. * Initializes the effect layer with the required options.
  48543. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48544. */
  48545. protected _init(options: Partial<IEffectLayerOptions>): void;
  48546. /**
  48547. * Generates the index buffer of the full screen quad blending to the main canvas.
  48548. */
  48549. private _generateIndexBuffer;
  48550. /**
  48551. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48552. */
  48553. private _generateVertexBuffer;
  48554. /**
  48555. * Sets the main texture desired size which is the closest power of two
  48556. * of the engine canvas size.
  48557. */
  48558. private _setMainTextureSize;
  48559. /**
  48560. * Creates the main texture for the effect layer.
  48561. */
  48562. protected _createMainTexture(): void;
  48563. /**
  48564. * Adds specific effects defines.
  48565. * @param defines The defines to add specifics to.
  48566. */
  48567. protected _addCustomEffectDefines(defines: string[]): void;
  48568. /**
  48569. * Checks for the readiness of the element composing the layer.
  48570. * @param subMesh the mesh to check for
  48571. * @param useInstances specify wether or not to use instances to render the mesh
  48572. * @param emissiveTexture the associated emissive texture used to generate the glow
  48573. * @return true if ready otherwise, false
  48574. */
  48575. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48576. /**
  48577. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48578. */
  48579. render(): void;
  48580. /**
  48581. * Determine if a given mesh will be used in the current effect.
  48582. * @param mesh mesh to test
  48583. * @returns true if the mesh will be used
  48584. */
  48585. hasMesh(mesh: AbstractMesh): boolean;
  48586. /**
  48587. * Returns true if the layer contains information to display, otherwise false.
  48588. * @returns true if the glow layer should be rendered
  48589. */
  48590. shouldRender(): boolean;
  48591. /**
  48592. * Returns true if the mesh should render, otherwise false.
  48593. * @param mesh The mesh to render
  48594. * @returns true if it should render otherwise false
  48595. */
  48596. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48597. /**
  48598. * Returns true if the mesh can be rendered, otherwise false.
  48599. * @param mesh The mesh to render
  48600. * @param material The material used on the mesh
  48601. * @returns true if it can be rendered otherwise false
  48602. */
  48603. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48604. /**
  48605. * Returns true if the mesh should render, otherwise false.
  48606. * @param mesh The mesh to render
  48607. * @returns true if it should render otherwise false
  48608. */
  48609. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48610. /**
  48611. * Renders the submesh passed in parameter to the generation map.
  48612. */
  48613. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48614. /**
  48615. * Rebuild the required buffers.
  48616. * @hidden Internal use only.
  48617. */
  48618. _rebuild(): void;
  48619. /**
  48620. * Dispose only the render target textures and post process.
  48621. */
  48622. private _disposeTextureAndPostProcesses;
  48623. /**
  48624. * Dispose the highlight layer and free resources.
  48625. */
  48626. dispose(): void;
  48627. /**
  48628. * Gets the class name of the effect layer
  48629. * @returns the string with the class name of the effect layer
  48630. */
  48631. getClassName(): string;
  48632. /**
  48633. * Creates an effect layer from parsed effect layer data
  48634. * @param parsedEffectLayer defines effect layer data
  48635. * @param scene defines the current scene
  48636. * @param rootUrl defines the root URL containing the effect layer information
  48637. * @returns a parsed effect Layer
  48638. */
  48639. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48640. }
  48641. }
  48642. declare module BABYLON {
  48643. interface AbstractScene {
  48644. /**
  48645. * The list of effect layers (highlights/glow) added to the scene
  48646. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48647. * @see http://doc.babylonjs.com/how_to/glow_layer
  48648. */
  48649. effectLayers: Array<EffectLayer>;
  48650. /**
  48651. * Removes the given effect layer from this scene.
  48652. * @param toRemove defines the effect layer to remove
  48653. * @returns the index of the removed effect layer
  48654. */
  48655. removeEffectLayer(toRemove: EffectLayer): number;
  48656. /**
  48657. * Adds the given effect layer to this scene
  48658. * @param newEffectLayer defines the effect layer to add
  48659. */
  48660. addEffectLayer(newEffectLayer: EffectLayer): void;
  48661. }
  48662. /**
  48663. * Defines the layer scene component responsible to manage any effect layers
  48664. * in a given scene.
  48665. */
  48666. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48667. /**
  48668. * The component name helpfull to identify the component in the list of scene components.
  48669. */
  48670. readonly name: string;
  48671. /**
  48672. * The scene the component belongs to.
  48673. */
  48674. scene: Scene;
  48675. private _engine;
  48676. private _renderEffects;
  48677. private _needStencil;
  48678. private _previousStencilState;
  48679. /**
  48680. * Creates a new instance of the component for the given scene
  48681. * @param scene Defines the scene to register the component in
  48682. */
  48683. constructor(scene: Scene);
  48684. /**
  48685. * Registers the component in a given scene
  48686. */
  48687. register(): void;
  48688. /**
  48689. * Rebuilds the elements related to this component in case of
  48690. * context lost for instance.
  48691. */
  48692. rebuild(): void;
  48693. /**
  48694. * Serializes the component data to the specified json object
  48695. * @param serializationObject The object to serialize to
  48696. */
  48697. serialize(serializationObject: any): void;
  48698. /**
  48699. * Adds all the elements from the container to the scene
  48700. * @param container the container holding the elements
  48701. */
  48702. addFromContainer(container: AbstractScene): void;
  48703. /**
  48704. * Removes all the elements in the container from the scene
  48705. * @param container contains the elements to remove
  48706. * @param dispose if the removed element should be disposed (default: false)
  48707. */
  48708. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48709. /**
  48710. * Disposes the component and the associated ressources.
  48711. */
  48712. dispose(): void;
  48713. private _isReadyForMesh;
  48714. private _renderMainTexture;
  48715. private _setStencil;
  48716. private _setStencilBack;
  48717. private _draw;
  48718. private _drawCamera;
  48719. private _drawRenderingGroup;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /** @hidden */
  48724. export var glowMapMergePixelShader: {
  48725. name: string;
  48726. shader: string;
  48727. };
  48728. }
  48729. declare module BABYLON {
  48730. /** @hidden */
  48731. export var glowMapMergeVertexShader: {
  48732. name: string;
  48733. shader: string;
  48734. };
  48735. }
  48736. declare module BABYLON {
  48737. interface AbstractScene {
  48738. /**
  48739. * Return a the first highlight layer of the scene with a given name.
  48740. * @param name The name of the highlight layer to look for.
  48741. * @return The highlight layer if found otherwise null.
  48742. */
  48743. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48744. }
  48745. /**
  48746. * Glow layer options. This helps customizing the behaviour
  48747. * of the glow layer.
  48748. */
  48749. export interface IGlowLayerOptions {
  48750. /**
  48751. * Multiplication factor apply to the canvas size to compute the render target size
  48752. * used to generated the glowing objects (the smaller the faster).
  48753. */
  48754. mainTextureRatio: number;
  48755. /**
  48756. * Enforces a fixed size texture to ensure resize independant blur.
  48757. */
  48758. mainTextureFixedSize?: number;
  48759. /**
  48760. * How big is the kernel of the blur texture.
  48761. */
  48762. blurKernelSize: number;
  48763. /**
  48764. * The camera attached to the layer.
  48765. */
  48766. camera: Nullable<Camera>;
  48767. /**
  48768. * Enable MSAA by chosing the number of samples.
  48769. */
  48770. mainTextureSamples?: number;
  48771. /**
  48772. * The rendering group to draw the layer in.
  48773. */
  48774. renderingGroupId: number;
  48775. }
  48776. /**
  48777. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48778. *
  48779. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48780. * glowy meshes to your scene.
  48781. *
  48782. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48783. */
  48784. export class GlowLayer extends EffectLayer {
  48785. /**
  48786. * Effect Name of the layer.
  48787. */
  48788. static readonly EffectName: string;
  48789. /**
  48790. * The default blur kernel size used for the glow.
  48791. */
  48792. static DefaultBlurKernelSize: number;
  48793. /**
  48794. * The default texture size ratio used for the glow.
  48795. */
  48796. static DefaultTextureRatio: number;
  48797. /**
  48798. * Sets the kernel size of the blur.
  48799. */
  48800. /**
  48801. * Gets the kernel size of the blur.
  48802. */
  48803. blurKernelSize: number;
  48804. /**
  48805. * Sets the glow intensity.
  48806. */
  48807. /**
  48808. * Gets the glow intensity.
  48809. */
  48810. intensity: number;
  48811. private _options;
  48812. private _intensity;
  48813. private _horizontalBlurPostprocess1;
  48814. private _verticalBlurPostprocess1;
  48815. private _horizontalBlurPostprocess2;
  48816. private _verticalBlurPostprocess2;
  48817. private _blurTexture1;
  48818. private _blurTexture2;
  48819. private _postProcesses1;
  48820. private _postProcesses2;
  48821. private _includedOnlyMeshes;
  48822. private _excludedMeshes;
  48823. /**
  48824. * Callback used to let the user override the color selection on a per mesh basis
  48825. */
  48826. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48827. /**
  48828. * Callback used to let the user override the texture selection on a per mesh basis
  48829. */
  48830. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48831. /**
  48832. * Instantiates a new glow Layer and references it to the scene.
  48833. * @param name The name of the layer
  48834. * @param scene The scene to use the layer in
  48835. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48836. */
  48837. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48838. /**
  48839. * Get the effect name of the layer.
  48840. * @return The effect name
  48841. */
  48842. getEffectName(): string;
  48843. /**
  48844. * Create the merge effect. This is the shader use to blit the information back
  48845. * to the main canvas at the end of the scene rendering.
  48846. */
  48847. protected _createMergeEffect(): Effect;
  48848. /**
  48849. * Creates the render target textures and post processes used in the glow layer.
  48850. */
  48851. protected _createTextureAndPostProcesses(): void;
  48852. /**
  48853. * Checks for the readiness of the element composing the layer.
  48854. * @param subMesh the mesh to check for
  48855. * @param useInstances specify wether or not to use instances to render the mesh
  48856. * @param emissiveTexture the associated emissive texture used to generate the glow
  48857. * @return true if ready otherwise, false
  48858. */
  48859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48860. /**
  48861. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48862. */
  48863. needStencil(): boolean;
  48864. /**
  48865. * Returns true if the mesh can be rendered, otherwise false.
  48866. * @param mesh The mesh to render
  48867. * @param material The material used on the mesh
  48868. * @returns true if it can be rendered otherwise false
  48869. */
  48870. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48871. /**
  48872. * Implementation specific of rendering the generating effect on the main canvas.
  48873. * @param effect The effect used to render through
  48874. */
  48875. protected _internalRender(effect: Effect): void;
  48876. /**
  48877. * Sets the required values for both the emissive texture and and the main color.
  48878. */
  48879. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48880. /**
  48881. * Returns true if the mesh should render, otherwise false.
  48882. * @param mesh The mesh to render
  48883. * @returns true if it should render otherwise false
  48884. */
  48885. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48886. /**
  48887. * Adds specific effects defines.
  48888. * @param defines The defines to add specifics to.
  48889. */
  48890. protected _addCustomEffectDefines(defines: string[]): void;
  48891. /**
  48892. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48893. * @param mesh The mesh to exclude from the glow layer
  48894. */
  48895. addExcludedMesh(mesh: Mesh): void;
  48896. /**
  48897. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48898. * @param mesh The mesh to remove
  48899. */
  48900. removeExcludedMesh(mesh: Mesh): void;
  48901. /**
  48902. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48903. * @param mesh The mesh to include in the glow layer
  48904. */
  48905. addIncludedOnlyMesh(mesh: Mesh): void;
  48906. /**
  48907. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48908. * @param mesh The mesh to remove
  48909. */
  48910. removeIncludedOnlyMesh(mesh: Mesh): void;
  48911. /**
  48912. * Determine if a given mesh will be used in the glow layer
  48913. * @param mesh The mesh to test
  48914. * @returns true if the mesh will be highlighted by the current glow layer
  48915. */
  48916. hasMesh(mesh: AbstractMesh): boolean;
  48917. /**
  48918. * Free any resources and references associated to a mesh.
  48919. * Internal use
  48920. * @param mesh The mesh to free.
  48921. * @hidden
  48922. */
  48923. _disposeMesh(mesh: Mesh): void;
  48924. /**
  48925. * Gets the class name of the effect layer
  48926. * @returns the string with the class name of the effect layer
  48927. */
  48928. getClassName(): string;
  48929. /**
  48930. * Serializes this glow layer
  48931. * @returns a serialized glow layer object
  48932. */
  48933. serialize(): any;
  48934. /**
  48935. * Creates a Glow Layer from parsed glow layer data
  48936. * @param parsedGlowLayer defines glow layer data
  48937. * @param scene defines the current scene
  48938. * @param rootUrl defines the root URL containing the glow layer information
  48939. * @returns a parsed Glow Layer
  48940. */
  48941. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48942. }
  48943. }
  48944. declare module BABYLON {
  48945. /** @hidden */
  48946. export var glowBlurPostProcessPixelShader: {
  48947. name: string;
  48948. shader: string;
  48949. };
  48950. }
  48951. declare module BABYLON {
  48952. interface AbstractScene {
  48953. /**
  48954. * Return a the first highlight layer of the scene with a given name.
  48955. * @param name The name of the highlight layer to look for.
  48956. * @return The highlight layer if found otherwise null.
  48957. */
  48958. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48959. }
  48960. /**
  48961. * Highlight layer options. This helps customizing the behaviour
  48962. * of the highlight layer.
  48963. */
  48964. export interface IHighlightLayerOptions {
  48965. /**
  48966. * Multiplication factor apply to the canvas size to compute the render target size
  48967. * used to generated the glowing objects (the smaller the faster).
  48968. */
  48969. mainTextureRatio: number;
  48970. /**
  48971. * Enforces a fixed size texture to ensure resize independant blur.
  48972. */
  48973. mainTextureFixedSize?: number;
  48974. /**
  48975. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48976. * of the picture to blur (the smaller the faster).
  48977. */
  48978. blurTextureSizeRatio: number;
  48979. /**
  48980. * How big in texel of the blur texture is the vertical blur.
  48981. */
  48982. blurVerticalSize: number;
  48983. /**
  48984. * How big in texel of the blur texture is the horizontal blur.
  48985. */
  48986. blurHorizontalSize: number;
  48987. /**
  48988. * Alpha blending mode used to apply the blur. Default is combine.
  48989. */
  48990. alphaBlendingMode: number;
  48991. /**
  48992. * The camera attached to the layer.
  48993. */
  48994. camera: Nullable<Camera>;
  48995. /**
  48996. * Should we display highlight as a solid stroke?
  48997. */
  48998. isStroke?: boolean;
  48999. /**
  49000. * The rendering group to draw the layer in.
  49001. */
  49002. renderingGroupId: number;
  49003. }
  49004. /**
  49005. * The highlight layer Helps adding a glow effect around a mesh.
  49006. *
  49007. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49008. * glowy meshes to your scene.
  49009. *
  49010. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49011. */
  49012. export class HighlightLayer extends EffectLayer {
  49013. name: string;
  49014. /**
  49015. * Effect Name of the highlight layer.
  49016. */
  49017. static readonly EffectName: string;
  49018. /**
  49019. * The neutral color used during the preparation of the glow effect.
  49020. * This is black by default as the blend operation is a blend operation.
  49021. */
  49022. static NeutralColor: Color4;
  49023. /**
  49024. * Stencil value used for glowing meshes.
  49025. */
  49026. static GlowingMeshStencilReference: number;
  49027. /**
  49028. * Stencil value used for the other meshes in the scene.
  49029. */
  49030. static NormalMeshStencilReference: number;
  49031. /**
  49032. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49033. */
  49034. innerGlow: boolean;
  49035. /**
  49036. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49037. */
  49038. outerGlow: boolean;
  49039. /**
  49040. * Specifies the horizontal size of the blur.
  49041. */
  49042. /**
  49043. * Gets the horizontal size of the blur.
  49044. */
  49045. blurHorizontalSize: number;
  49046. /**
  49047. * Specifies the vertical size of the blur.
  49048. */
  49049. /**
  49050. * Gets the vertical size of the blur.
  49051. */
  49052. blurVerticalSize: number;
  49053. /**
  49054. * An event triggered when the highlight layer is being blurred.
  49055. */
  49056. onBeforeBlurObservable: Observable<HighlightLayer>;
  49057. /**
  49058. * An event triggered when the highlight layer has been blurred.
  49059. */
  49060. onAfterBlurObservable: Observable<HighlightLayer>;
  49061. private _instanceGlowingMeshStencilReference;
  49062. private _options;
  49063. private _downSamplePostprocess;
  49064. private _horizontalBlurPostprocess;
  49065. private _verticalBlurPostprocess;
  49066. private _blurTexture;
  49067. private _meshes;
  49068. private _excludedMeshes;
  49069. /**
  49070. * Instantiates a new highlight Layer and references it to the scene..
  49071. * @param name The name of the layer
  49072. * @param scene The scene to use the layer in
  49073. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49074. */
  49075. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49076. /**
  49077. * Get the effect name of the layer.
  49078. * @return The effect name
  49079. */
  49080. getEffectName(): string;
  49081. /**
  49082. * Create the merge effect. This is the shader use to blit the information back
  49083. * to the main canvas at the end of the scene rendering.
  49084. */
  49085. protected _createMergeEffect(): Effect;
  49086. /**
  49087. * Creates the render target textures and post processes used in the highlight layer.
  49088. */
  49089. protected _createTextureAndPostProcesses(): void;
  49090. /**
  49091. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49092. */
  49093. needStencil(): boolean;
  49094. /**
  49095. * Checks for the readiness of the element composing the layer.
  49096. * @param subMesh the mesh to check for
  49097. * @param useInstances specify wether or not to use instances to render the mesh
  49098. * @param emissiveTexture the associated emissive texture used to generate the glow
  49099. * @return true if ready otherwise, false
  49100. */
  49101. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49102. /**
  49103. * Implementation specific of rendering the generating effect on the main canvas.
  49104. * @param effect The effect used to render through
  49105. */
  49106. protected _internalRender(effect: Effect): void;
  49107. /**
  49108. * Returns true if the layer contains information to display, otherwise false.
  49109. */
  49110. shouldRender(): boolean;
  49111. /**
  49112. * Returns true if the mesh should render, otherwise false.
  49113. * @param mesh The mesh to render
  49114. * @returns true if it should render otherwise false
  49115. */
  49116. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49117. /**
  49118. * Sets the required values for both the emissive texture and and the main color.
  49119. */
  49120. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49121. /**
  49122. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49123. * @param mesh The mesh to exclude from the highlight layer
  49124. */
  49125. addExcludedMesh(mesh: Mesh): void;
  49126. /**
  49127. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49128. * @param mesh The mesh to highlight
  49129. */
  49130. removeExcludedMesh(mesh: Mesh): void;
  49131. /**
  49132. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49133. * @param mesh mesh to test
  49134. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49135. */
  49136. hasMesh(mesh: AbstractMesh): boolean;
  49137. /**
  49138. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49139. * @param mesh The mesh to highlight
  49140. * @param color The color of the highlight
  49141. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49142. */
  49143. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49144. /**
  49145. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49146. * @param mesh The mesh to highlight
  49147. */
  49148. removeMesh(mesh: Mesh): void;
  49149. /**
  49150. * Force the stencil to the normal expected value for none glowing parts
  49151. */
  49152. private _defaultStencilReference;
  49153. /**
  49154. * Free any resources and references associated to a mesh.
  49155. * Internal use
  49156. * @param mesh The mesh to free.
  49157. * @hidden
  49158. */
  49159. _disposeMesh(mesh: Mesh): void;
  49160. /**
  49161. * Dispose the highlight layer and free resources.
  49162. */
  49163. dispose(): void;
  49164. /**
  49165. * Gets the class name of the effect layer
  49166. * @returns the string with the class name of the effect layer
  49167. */
  49168. getClassName(): string;
  49169. /**
  49170. * Serializes this Highlight layer
  49171. * @returns a serialized Highlight layer object
  49172. */
  49173. serialize(): any;
  49174. /**
  49175. * Creates a Highlight layer from parsed Highlight layer data
  49176. * @param parsedHightlightLayer defines the Highlight layer data
  49177. * @param scene defines the current scene
  49178. * @param rootUrl defines the root URL containing the Highlight layer information
  49179. * @returns a parsed Highlight layer
  49180. */
  49181. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49182. }
  49183. }
  49184. declare module BABYLON {
  49185. interface AbstractScene {
  49186. /**
  49187. * The list of layers (background and foreground) of the scene
  49188. */
  49189. layers: Array<Layer>;
  49190. }
  49191. /**
  49192. * Defines the layer scene component responsible to manage any layers
  49193. * in a given scene.
  49194. */
  49195. export class LayerSceneComponent implements ISceneComponent {
  49196. /**
  49197. * The component name helpfull to identify the component in the list of scene components.
  49198. */
  49199. readonly name: string;
  49200. /**
  49201. * The scene the component belongs to.
  49202. */
  49203. scene: Scene;
  49204. private _engine;
  49205. /**
  49206. * Creates a new instance of the component for the given scene
  49207. * @param scene Defines the scene to register the component in
  49208. */
  49209. constructor(scene: Scene);
  49210. /**
  49211. * Registers the component in a given scene
  49212. */
  49213. register(): void;
  49214. /**
  49215. * Rebuilds the elements related to this component in case of
  49216. * context lost for instance.
  49217. */
  49218. rebuild(): void;
  49219. /**
  49220. * Disposes the component and the associated ressources.
  49221. */
  49222. dispose(): void;
  49223. private _draw;
  49224. private _drawCameraPredicate;
  49225. private _drawCameraBackground;
  49226. private _drawCameraForeground;
  49227. private _drawRenderTargetPredicate;
  49228. private _drawRenderTargetBackground;
  49229. private _drawRenderTargetForeground;
  49230. /**
  49231. * Adds all the elements from the container to the scene
  49232. * @param container the container holding the elements
  49233. */
  49234. addFromContainer(container: AbstractScene): void;
  49235. /**
  49236. * Removes all the elements in the container from the scene
  49237. * @param container contains the elements to remove
  49238. * @param dispose if the removed element should be disposed (default: false)
  49239. */
  49240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49241. }
  49242. }
  49243. declare module BABYLON {
  49244. /** @hidden */
  49245. export var layerPixelShader: {
  49246. name: string;
  49247. shader: string;
  49248. };
  49249. }
  49250. declare module BABYLON {
  49251. /** @hidden */
  49252. export var layerVertexShader: {
  49253. name: string;
  49254. shader: string;
  49255. };
  49256. }
  49257. declare module BABYLON {
  49258. /**
  49259. * This represents a full screen 2d layer.
  49260. * This can be useful to display a picture in the background of your scene for instance.
  49261. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49262. */
  49263. export class Layer {
  49264. /**
  49265. * Define the name of the layer.
  49266. */
  49267. name: string;
  49268. /**
  49269. * Define the texture the layer should display.
  49270. */
  49271. texture: Nullable<Texture>;
  49272. /**
  49273. * Is the layer in background or foreground.
  49274. */
  49275. isBackground: boolean;
  49276. /**
  49277. * Define the color of the layer (instead of texture).
  49278. */
  49279. color: Color4;
  49280. /**
  49281. * Define the scale of the layer in order to zoom in out of the texture.
  49282. */
  49283. scale: Vector2;
  49284. /**
  49285. * Define an offset for the layer in order to shift the texture.
  49286. */
  49287. offset: Vector2;
  49288. /**
  49289. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49290. */
  49291. alphaBlendingMode: number;
  49292. /**
  49293. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49294. * Alpha test will not mix with the background color in case of transparency.
  49295. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49296. */
  49297. alphaTest: boolean;
  49298. /**
  49299. * Define a mask to restrict the layer to only some of the scene cameras.
  49300. */
  49301. layerMask: number;
  49302. /**
  49303. * Define the list of render target the layer is visible into.
  49304. */
  49305. renderTargetTextures: RenderTargetTexture[];
  49306. /**
  49307. * Define if the layer is only used in renderTarget or if it also
  49308. * renders in the main frame buffer of the canvas.
  49309. */
  49310. renderOnlyInRenderTargetTextures: boolean;
  49311. private _scene;
  49312. private _vertexBuffers;
  49313. private _indexBuffer;
  49314. private _effect;
  49315. private _alphaTestEffect;
  49316. /**
  49317. * An event triggered when the layer is disposed.
  49318. */
  49319. onDisposeObservable: Observable<Layer>;
  49320. private _onDisposeObserver;
  49321. /**
  49322. * Back compatibility with callback before the onDisposeObservable existed.
  49323. * The set callback will be triggered when the layer has been disposed.
  49324. */
  49325. onDispose: () => void;
  49326. /**
  49327. * An event triggered before rendering the scene
  49328. */
  49329. onBeforeRenderObservable: Observable<Layer>;
  49330. private _onBeforeRenderObserver;
  49331. /**
  49332. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49333. * The set callback will be triggered just before rendering the layer.
  49334. */
  49335. onBeforeRender: () => void;
  49336. /**
  49337. * An event triggered after rendering the scene
  49338. */
  49339. onAfterRenderObservable: Observable<Layer>;
  49340. private _onAfterRenderObserver;
  49341. /**
  49342. * Back compatibility with callback before the onAfterRenderObservable existed.
  49343. * The set callback will be triggered just after rendering the layer.
  49344. */
  49345. onAfterRender: () => void;
  49346. /**
  49347. * Instantiates a new layer.
  49348. * This represents a full screen 2d layer.
  49349. * This can be useful to display a picture in the background of your scene for instance.
  49350. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49351. * @param name Define the name of the layer in the scene
  49352. * @param imgUrl Define the url of the texture to display in the layer
  49353. * @param scene Define the scene the layer belongs to
  49354. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49355. * @param color Defines a color for the layer
  49356. */
  49357. constructor(
  49358. /**
  49359. * Define the name of the layer.
  49360. */
  49361. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49362. private _createIndexBuffer;
  49363. /** @hidden */
  49364. _rebuild(): void;
  49365. /**
  49366. * Renders the layer in the scene.
  49367. */
  49368. render(): void;
  49369. /**
  49370. * Disposes and releases the associated ressources.
  49371. */
  49372. dispose(): void;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /** @hidden */
  49377. export var lensFlarePixelShader: {
  49378. name: string;
  49379. shader: string;
  49380. };
  49381. }
  49382. declare module BABYLON {
  49383. /** @hidden */
  49384. export var lensFlareVertexShader: {
  49385. name: string;
  49386. shader: string;
  49387. };
  49388. }
  49389. declare module BABYLON {
  49390. /**
  49391. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49392. * It is usually composed of several `lensFlare`.
  49393. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49394. */
  49395. export class LensFlareSystem {
  49396. /**
  49397. * Define the name of the lens flare system
  49398. */
  49399. name: string;
  49400. /**
  49401. * List of lens flares used in this system.
  49402. */
  49403. lensFlares: LensFlare[];
  49404. /**
  49405. * Define a limit from the border the lens flare can be visible.
  49406. */
  49407. borderLimit: number;
  49408. /**
  49409. * Define a viewport border we do not want to see the lens flare in.
  49410. */
  49411. viewportBorder: number;
  49412. /**
  49413. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49414. */
  49415. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49416. /**
  49417. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49418. */
  49419. layerMask: number;
  49420. /**
  49421. * Define the id of the lens flare system in the scene.
  49422. * (equal to name by default)
  49423. */
  49424. id: string;
  49425. private _scene;
  49426. private _emitter;
  49427. private _vertexBuffers;
  49428. private _indexBuffer;
  49429. private _effect;
  49430. private _positionX;
  49431. private _positionY;
  49432. private _isEnabled;
  49433. /** @hidden */
  49434. static _SceneComponentInitialization: (scene: Scene) => void;
  49435. /**
  49436. * Instantiates a lens flare system.
  49437. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49438. * It is usually composed of several `lensFlare`.
  49439. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49440. * @param name Define the name of the lens flare system in the scene
  49441. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49442. * @param scene Define the scene the lens flare system belongs to
  49443. */
  49444. constructor(
  49445. /**
  49446. * Define the name of the lens flare system
  49447. */
  49448. name: string, emitter: any, scene: Scene);
  49449. /**
  49450. * Define if the lens flare system is enabled.
  49451. */
  49452. isEnabled: boolean;
  49453. /**
  49454. * Get the scene the effects belongs to.
  49455. * @returns the scene holding the lens flare system
  49456. */
  49457. getScene(): Scene;
  49458. /**
  49459. * Get the emitter of the lens flare system.
  49460. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49461. * @returns the emitter of the lens flare system
  49462. */
  49463. getEmitter(): any;
  49464. /**
  49465. * Set the emitter of the lens flare system.
  49466. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49467. * @param newEmitter Define the new emitter of the system
  49468. */
  49469. setEmitter(newEmitter: any): void;
  49470. /**
  49471. * Get the lens flare system emitter position.
  49472. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49473. * @returns the position
  49474. */
  49475. getEmitterPosition(): Vector3;
  49476. /**
  49477. * @hidden
  49478. */
  49479. computeEffectivePosition(globalViewport: Viewport): boolean;
  49480. /** @hidden */
  49481. _isVisible(): boolean;
  49482. /**
  49483. * @hidden
  49484. */
  49485. render(): boolean;
  49486. /**
  49487. * Dispose and release the lens flare with its associated resources.
  49488. */
  49489. dispose(): void;
  49490. /**
  49491. * Parse a lens flare system from a JSON repressentation
  49492. * @param parsedLensFlareSystem Define the JSON to parse
  49493. * @param scene Define the scene the parsed system should be instantiated in
  49494. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49495. * @returns the parsed system
  49496. */
  49497. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49498. /**
  49499. * Serialize the current Lens Flare System into a JSON representation.
  49500. * @returns the serialized JSON
  49501. */
  49502. serialize(): any;
  49503. }
  49504. }
  49505. declare module BABYLON {
  49506. /**
  49507. * This represents one of the lens effect in a `lensFlareSystem`.
  49508. * It controls one of the indiviual texture used in the effect.
  49509. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49510. */
  49511. export class LensFlare {
  49512. /**
  49513. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49514. */
  49515. size: number;
  49516. /**
  49517. * 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.
  49518. */
  49519. position: number;
  49520. /**
  49521. * Define the lens color.
  49522. */
  49523. color: Color3;
  49524. /**
  49525. * Define the lens texture.
  49526. */
  49527. texture: Nullable<Texture>;
  49528. /**
  49529. * Define the alpha mode to render this particular lens.
  49530. */
  49531. alphaMode: number;
  49532. private _system;
  49533. /**
  49534. * Creates a new Lens Flare.
  49535. * This represents one of the lens effect in a `lensFlareSystem`.
  49536. * It controls one of the indiviual texture used in the effect.
  49537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49538. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49539. * @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.
  49540. * @param color Define the lens color
  49541. * @param imgUrl Define the lens texture url
  49542. * @param system Define the `lensFlareSystem` this flare is part of
  49543. * @returns The newly created Lens Flare
  49544. */
  49545. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49546. /**
  49547. * Instantiates a new Lens Flare.
  49548. * This represents one of the lens effect in a `lensFlareSystem`.
  49549. * It controls one of the indiviual texture used in the effect.
  49550. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49551. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49552. * @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.
  49553. * @param color Define the lens color
  49554. * @param imgUrl Define the lens texture url
  49555. * @param system Define the `lensFlareSystem` this flare is part of
  49556. */
  49557. constructor(
  49558. /**
  49559. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49560. */
  49561. size: number,
  49562. /**
  49563. * 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.
  49564. */
  49565. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49566. /**
  49567. * Dispose and release the lens flare with its associated resources.
  49568. */
  49569. dispose(): void;
  49570. }
  49571. }
  49572. declare module BABYLON {
  49573. interface AbstractScene {
  49574. /**
  49575. * The list of lens flare system added to the scene
  49576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49577. */
  49578. lensFlareSystems: Array<LensFlareSystem>;
  49579. /**
  49580. * Removes the given lens flare system from this scene.
  49581. * @param toRemove The lens flare system to remove
  49582. * @returns The index of the removed lens flare system
  49583. */
  49584. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49585. /**
  49586. * Adds the given lens flare system to this scene
  49587. * @param newLensFlareSystem The lens flare system to add
  49588. */
  49589. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49590. /**
  49591. * Gets a lens flare system using its name
  49592. * @param name defines the name to look for
  49593. * @returns the lens flare system or null if not found
  49594. */
  49595. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49596. /**
  49597. * Gets a lens flare system using its id
  49598. * @param id defines the id to look for
  49599. * @returns the lens flare system or null if not found
  49600. */
  49601. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49602. }
  49603. /**
  49604. * Defines the lens flare scene component responsible to manage any lens flares
  49605. * in a given scene.
  49606. */
  49607. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49608. /**
  49609. * The component name helpfull to identify the component in the list of scene components.
  49610. */
  49611. readonly name: string;
  49612. /**
  49613. * The scene the component belongs to.
  49614. */
  49615. scene: Scene;
  49616. /**
  49617. * Creates a new instance of the component for the given scene
  49618. * @param scene Defines the scene to register the component in
  49619. */
  49620. constructor(scene: Scene);
  49621. /**
  49622. * Registers the component in a given scene
  49623. */
  49624. register(): void;
  49625. /**
  49626. * Rebuilds the elements related to this component in case of
  49627. * context lost for instance.
  49628. */
  49629. rebuild(): void;
  49630. /**
  49631. * Adds all the elements from the container to the scene
  49632. * @param container the container holding the elements
  49633. */
  49634. addFromContainer(container: AbstractScene): void;
  49635. /**
  49636. * Removes all the elements in the container from the scene
  49637. * @param container contains the elements to remove
  49638. * @param dispose if the removed element should be disposed (default: false)
  49639. */
  49640. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49641. /**
  49642. * Serializes the component data to the specified json object
  49643. * @param serializationObject The object to serialize to
  49644. */
  49645. serialize(serializationObject: any): void;
  49646. /**
  49647. * Disposes the component and the associated ressources.
  49648. */
  49649. dispose(): void;
  49650. private _draw;
  49651. }
  49652. }
  49653. declare module BABYLON {
  49654. /**
  49655. * Defines the shadow generator component responsible to manage any shadow generators
  49656. * in a given scene.
  49657. */
  49658. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49659. /**
  49660. * The component name helpfull to identify the component in the list of scene components.
  49661. */
  49662. readonly name: string;
  49663. /**
  49664. * The scene the component belongs to.
  49665. */
  49666. scene: Scene;
  49667. /**
  49668. * Creates a new instance of the component for the given scene
  49669. * @param scene Defines the scene to register the component in
  49670. */
  49671. constructor(scene: Scene);
  49672. /**
  49673. * Registers the component in a given scene
  49674. */
  49675. register(): void;
  49676. /**
  49677. * Rebuilds the elements related to this component in case of
  49678. * context lost for instance.
  49679. */
  49680. rebuild(): void;
  49681. /**
  49682. * Serializes the component data to the specified json object
  49683. * @param serializationObject The object to serialize to
  49684. */
  49685. serialize(serializationObject: any): void;
  49686. /**
  49687. * Adds all the elements from the container to the scene
  49688. * @param container the container holding the elements
  49689. */
  49690. addFromContainer(container: AbstractScene): void;
  49691. /**
  49692. * Removes all the elements in the container from the scene
  49693. * @param container contains the elements to remove
  49694. * @param dispose if the removed element should be disposed (default: false)
  49695. */
  49696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49697. /**
  49698. * Rebuilds the elements related to this component in case of
  49699. * context lost for instance.
  49700. */
  49701. dispose(): void;
  49702. private _gatherRenderTargets;
  49703. }
  49704. }
  49705. declare module BABYLON {
  49706. /**
  49707. * A point light is a light defined by an unique point in world space.
  49708. * The light is emitted in every direction from this point.
  49709. * A good example of a point light is a standard light bulb.
  49710. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49711. */
  49712. export class PointLight extends ShadowLight {
  49713. private _shadowAngle;
  49714. /**
  49715. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49716. * This specifies what angle the shadow will use to be created.
  49717. *
  49718. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49719. */
  49720. /**
  49721. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49722. * This specifies what angle the shadow will use to be created.
  49723. *
  49724. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49725. */
  49726. shadowAngle: number;
  49727. /**
  49728. * Gets the direction if it has been set.
  49729. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49730. */
  49731. /**
  49732. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49733. */
  49734. direction: Vector3;
  49735. /**
  49736. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49737. * A PointLight emits the light in every direction.
  49738. * It can cast shadows.
  49739. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49740. * ```javascript
  49741. * var pointLight = new PointLight("pl", camera.position, scene);
  49742. * ```
  49743. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49744. * @param name The light friendly name
  49745. * @param position The position of the point light in the scene
  49746. * @param scene The scene the lights belongs to
  49747. */
  49748. constructor(name: string, position: Vector3, scene: Scene);
  49749. /**
  49750. * Returns the string "PointLight"
  49751. * @returns the class name
  49752. */
  49753. getClassName(): string;
  49754. /**
  49755. * Returns the integer 0.
  49756. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49757. */
  49758. getTypeID(): number;
  49759. /**
  49760. * Specifies wether or not the shadowmap should be a cube texture.
  49761. * @returns true if the shadowmap needs to be a cube texture.
  49762. */
  49763. needCube(): boolean;
  49764. /**
  49765. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49766. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49767. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49768. */
  49769. getShadowDirection(faceIndex?: number): Vector3;
  49770. /**
  49771. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49772. * - fov = PI / 2
  49773. * - aspect ratio : 1.0
  49774. * - z-near and far equal to the active camera minZ and maxZ.
  49775. * Returns the PointLight.
  49776. */
  49777. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49778. protected _buildUniformLayout(): void;
  49779. /**
  49780. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49781. * @param effect The effect to update
  49782. * @param lightIndex The index of the light in the effect to update
  49783. * @returns The point light
  49784. */
  49785. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49786. /**
  49787. * Prepares the list of defines specific to the light type.
  49788. * @param defines the list of defines
  49789. * @param lightIndex defines the index of the light for the effect
  49790. */
  49791. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /**
  49796. * Header information of HDR texture files.
  49797. */
  49798. export interface HDRInfo {
  49799. /**
  49800. * The height of the texture in pixels.
  49801. */
  49802. height: number;
  49803. /**
  49804. * The width of the texture in pixels.
  49805. */
  49806. width: number;
  49807. /**
  49808. * The index of the beginning of the data in the binary file.
  49809. */
  49810. dataPosition: number;
  49811. }
  49812. /**
  49813. * This groups tools to convert HDR texture to native colors array.
  49814. */
  49815. export class HDRTools {
  49816. private static Ldexp;
  49817. private static Rgbe2float;
  49818. private static readStringLine;
  49819. /**
  49820. * Reads header information from an RGBE texture stored in a native array.
  49821. * More information on this format are available here:
  49822. * https://en.wikipedia.org/wiki/RGBE_image_format
  49823. *
  49824. * @param uint8array The binary file stored in native array.
  49825. * @return The header information.
  49826. */
  49827. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49828. /**
  49829. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49830. * This RGBE texture needs to store the information as a panorama.
  49831. *
  49832. * More information on this format are available here:
  49833. * https://en.wikipedia.org/wiki/RGBE_image_format
  49834. *
  49835. * @param buffer The binary file stored in an array buffer.
  49836. * @param size The expected size of the extracted cubemap.
  49837. * @return The Cube Map information.
  49838. */
  49839. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49840. /**
  49841. * Returns the pixels data extracted from an RGBE texture.
  49842. * This pixels will be stored left to right up to down in the R G B order in one array.
  49843. *
  49844. * More information on this format are available here:
  49845. * https://en.wikipedia.org/wiki/RGBE_image_format
  49846. *
  49847. * @param uint8array The binary file stored in an array buffer.
  49848. * @param hdrInfo The header information of the file.
  49849. * @return The pixels data in RGB right to left up to down order.
  49850. */
  49851. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49852. private static RGBE_ReadPixels_RLE;
  49853. }
  49854. }
  49855. declare module BABYLON {
  49856. /**
  49857. * This represents a texture coming from an HDR input.
  49858. *
  49859. * The only supported format is currently panorama picture stored in RGBE format.
  49860. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49861. */
  49862. export class HDRCubeTexture extends BaseTexture {
  49863. private static _facesMapping;
  49864. private _generateHarmonics;
  49865. private _noMipmap;
  49866. private _textureMatrix;
  49867. private _size;
  49868. private _onLoad;
  49869. private _onError;
  49870. /**
  49871. * The texture URL.
  49872. */
  49873. url: string;
  49874. /**
  49875. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49876. */
  49877. coordinatesMode: number;
  49878. protected _isBlocking: boolean;
  49879. /**
  49880. * Sets wether or not the texture is blocking during loading.
  49881. */
  49882. /**
  49883. * Gets wether or not the texture is blocking during loading.
  49884. */
  49885. isBlocking: boolean;
  49886. protected _rotationY: number;
  49887. /**
  49888. * Sets texture matrix rotation angle around Y axis in radians.
  49889. */
  49890. /**
  49891. * Gets texture matrix rotation angle around Y axis radians.
  49892. */
  49893. rotationY: number;
  49894. /**
  49895. * Gets or sets the center of the bounding box associated with the cube texture
  49896. * It must define where the camera used to render the texture was set
  49897. */
  49898. boundingBoxPosition: Vector3;
  49899. private _boundingBoxSize;
  49900. /**
  49901. * Gets or sets the size of the bounding box associated with the cube texture
  49902. * When defined, the cubemap will switch to local mode
  49903. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49904. * @example https://www.babylonjs-playground.com/#RNASML
  49905. */
  49906. boundingBoxSize: Vector3;
  49907. /**
  49908. * Instantiates an HDRTexture from the following parameters.
  49909. *
  49910. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49911. * @param scene The scene the texture will be used in
  49912. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49913. * @param noMipmap Forces to not generate the mipmap if true
  49914. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49915. * @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)
  49916. * @param reserved Reserved flag for internal use.
  49917. */
  49918. 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>);
  49919. /**
  49920. * Get the current class name of the texture useful for serialization or dynamic coding.
  49921. * @returns "HDRCubeTexture"
  49922. */
  49923. getClassName(): string;
  49924. /**
  49925. * Occurs when the file is raw .hdr file.
  49926. */
  49927. private loadTexture;
  49928. clone(): HDRCubeTexture;
  49929. delayLoad(): void;
  49930. /**
  49931. * Get the texture reflection matrix used to rotate/transform the reflection.
  49932. * @returns the reflection matrix
  49933. */
  49934. getReflectionTextureMatrix(): Matrix;
  49935. /**
  49936. * Set the texture reflection matrix used to rotate/transform the reflection.
  49937. * @param value Define the reflection matrix to set
  49938. */
  49939. setReflectionTextureMatrix(value: Matrix): void;
  49940. /**
  49941. * Parses a JSON representation of an HDR Texture in order to create the texture
  49942. * @param parsedTexture Define the JSON representation
  49943. * @param scene Define the scene the texture should be created in
  49944. * @param rootUrl Define the root url in case we need to load relative dependencies
  49945. * @returns the newly created texture after parsing
  49946. */
  49947. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49948. serialize(): any;
  49949. }
  49950. }
  49951. declare module BABYLON {
  49952. /**
  49953. * Class used to control physics engine
  49954. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49955. */
  49956. export class PhysicsEngine implements IPhysicsEngine {
  49957. private _physicsPlugin;
  49958. /**
  49959. * Global value used to control the smallest number supported by the simulation
  49960. */
  49961. static Epsilon: number;
  49962. private _impostors;
  49963. private _joints;
  49964. /**
  49965. * Gets the gravity vector used by the simulation
  49966. */
  49967. gravity: Vector3;
  49968. /**
  49969. * Factory used to create the default physics plugin.
  49970. * @returns The default physics plugin
  49971. */
  49972. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49973. /**
  49974. * Creates a new Physics Engine
  49975. * @param gravity defines the gravity vector used by the simulation
  49976. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49977. */
  49978. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49979. /**
  49980. * Sets the gravity vector used by the simulation
  49981. * @param gravity defines the gravity vector to use
  49982. */
  49983. setGravity(gravity: Vector3): void;
  49984. /**
  49985. * Set the time step of the physics engine.
  49986. * Default is 1/60.
  49987. * To slow it down, enter 1/600 for example.
  49988. * To speed it up, 1/30
  49989. * @param newTimeStep defines the new timestep to apply to this world.
  49990. */
  49991. setTimeStep(newTimeStep?: number): void;
  49992. /**
  49993. * Get the time step of the physics engine.
  49994. * @returns the current time step
  49995. */
  49996. getTimeStep(): number;
  49997. /**
  49998. * Release all resources
  49999. */
  50000. dispose(): void;
  50001. /**
  50002. * Gets the name of the current physics plugin
  50003. * @returns the name of the plugin
  50004. */
  50005. getPhysicsPluginName(): string;
  50006. /**
  50007. * Adding a new impostor for the impostor tracking.
  50008. * This will be done by the impostor itself.
  50009. * @param impostor the impostor to add
  50010. */
  50011. addImpostor(impostor: PhysicsImpostor): void;
  50012. /**
  50013. * Remove an impostor from the engine.
  50014. * This impostor and its mesh will not longer be updated by the physics engine.
  50015. * @param impostor the impostor to remove
  50016. */
  50017. removeImpostor(impostor: PhysicsImpostor): void;
  50018. /**
  50019. * Add a joint to the physics engine
  50020. * @param mainImpostor defines the main impostor to which the joint is added.
  50021. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50022. * @param joint defines the joint that will connect both impostors.
  50023. */
  50024. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50025. /**
  50026. * Removes a joint from the simulation
  50027. * @param mainImpostor defines the impostor used with the joint
  50028. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50029. * @param joint defines the joint to remove
  50030. */
  50031. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50032. /**
  50033. * Called by the scene. No need to call it.
  50034. * @param delta defines the timespam between frames
  50035. */
  50036. _step(delta: number): void;
  50037. /**
  50038. * Gets the current plugin used to run the simulation
  50039. * @returns current plugin
  50040. */
  50041. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50042. /**
  50043. * Gets the list of physic impostors
  50044. * @returns an array of PhysicsImpostor
  50045. */
  50046. getImpostors(): Array<PhysicsImpostor>;
  50047. /**
  50048. * Gets the impostor for a physics enabled object
  50049. * @param object defines the object impersonated by the impostor
  50050. * @returns the PhysicsImpostor or null if not found
  50051. */
  50052. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50053. /**
  50054. * Gets the impostor for a physics body object
  50055. * @param body defines physics body used by the impostor
  50056. * @returns the PhysicsImpostor or null if not found
  50057. */
  50058. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50059. /**
  50060. * Does a raycast in the physics world
  50061. * @param from when should the ray start?
  50062. * @param to when should the ray end?
  50063. * @returns PhysicsRaycastResult
  50064. */
  50065. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50066. }
  50067. }
  50068. declare module BABYLON {
  50069. /** @hidden */
  50070. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50071. private _useDeltaForWorldStep;
  50072. world: any;
  50073. name: string;
  50074. private _physicsMaterials;
  50075. private _fixedTimeStep;
  50076. private _cannonRaycastResult;
  50077. private _raycastResult;
  50078. private _physicsBodysToRemoveAfterStep;
  50079. BJSCANNON: any;
  50080. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50081. setGravity(gravity: Vector3): void;
  50082. setTimeStep(timeStep: number): void;
  50083. getTimeStep(): number;
  50084. executeStep(delta: number): void;
  50085. private _removeMarkedPhysicsBodiesFromWorld;
  50086. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50087. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50088. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50089. private _processChildMeshes;
  50090. removePhysicsBody(impostor: PhysicsImpostor): void;
  50091. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50093. private _addMaterial;
  50094. private _checkWithEpsilon;
  50095. private _createShape;
  50096. private _createHeightmap;
  50097. private _minus90X;
  50098. private _plus90X;
  50099. private _tmpPosition;
  50100. private _tmpDeltaPosition;
  50101. private _tmpUnityRotation;
  50102. private _updatePhysicsBodyTransformation;
  50103. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50104. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50105. isSupported(): boolean;
  50106. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50107. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50108. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50109. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50111. getBodyMass(impostor: PhysicsImpostor): number;
  50112. getBodyFriction(impostor: PhysicsImpostor): number;
  50113. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50114. getBodyRestitution(impostor: PhysicsImpostor): number;
  50115. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50116. sleepBody(impostor: PhysicsImpostor): void;
  50117. wakeUpBody(impostor: PhysicsImpostor): void;
  50118. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50119. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50120. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50121. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50122. getRadius(impostor: PhysicsImpostor): number;
  50123. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50124. dispose(): void;
  50125. private _extendNamespace;
  50126. /**
  50127. * Does a raycast in the physics world
  50128. * @param from when should the ray start?
  50129. * @param to when should the ray end?
  50130. * @returns PhysicsRaycastResult
  50131. */
  50132. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50133. }
  50134. }
  50135. declare module BABYLON {
  50136. /** @hidden */
  50137. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50138. world: any;
  50139. name: string;
  50140. BJSOIMO: any;
  50141. private _raycastResult;
  50142. constructor(iterations?: number, oimoInjection?: any);
  50143. setGravity(gravity: Vector3): void;
  50144. setTimeStep(timeStep: number): void;
  50145. getTimeStep(): number;
  50146. private _tmpImpostorsArray;
  50147. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50148. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50149. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50150. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50151. private _tmpPositionVector;
  50152. removePhysicsBody(impostor: PhysicsImpostor): void;
  50153. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50154. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50155. isSupported(): boolean;
  50156. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50157. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50158. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50160. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50161. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50163. getBodyMass(impostor: PhysicsImpostor): number;
  50164. getBodyFriction(impostor: PhysicsImpostor): number;
  50165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50166. getBodyRestitution(impostor: PhysicsImpostor): number;
  50167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50168. sleepBody(impostor: PhysicsImpostor): void;
  50169. wakeUpBody(impostor: PhysicsImpostor): void;
  50170. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50171. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50172. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50173. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50174. getRadius(impostor: PhysicsImpostor): number;
  50175. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50176. dispose(): void;
  50177. /**
  50178. * Does a raycast in the physics world
  50179. * @param from when should the ray start?
  50180. * @param to when should the ray end?
  50181. * @returns PhysicsRaycastResult
  50182. */
  50183. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50184. }
  50185. }
  50186. declare module BABYLON {
  50187. /**
  50188. * Class containing static functions to help procedurally build meshes
  50189. */
  50190. export class RibbonBuilder {
  50191. /**
  50192. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50193. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50194. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50195. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50196. * * 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
  50197. * * 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
  50198. * * 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
  50199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50200. * * 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
  50201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50202. * * 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
  50203. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50204. * * 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
  50205. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50207. * @param name defines the name of the mesh
  50208. * @param options defines the options used to create the mesh
  50209. * @param scene defines the hosting scene
  50210. * @returns the ribbon mesh
  50211. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50212. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50213. */
  50214. static CreateRibbon(name: string, options: {
  50215. pathArray: Vector3[][];
  50216. closeArray?: boolean;
  50217. closePath?: boolean;
  50218. offset?: number;
  50219. updatable?: boolean;
  50220. sideOrientation?: number;
  50221. frontUVs?: Vector4;
  50222. backUVs?: Vector4;
  50223. instance?: Mesh;
  50224. invertUV?: boolean;
  50225. uvs?: Vector2[];
  50226. colors?: Color4[];
  50227. }, scene?: Nullable<Scene>): Mesh;
  50228. }
  50229. }
  50230. declare module BABYLON {
  50231. /**
  50232. * Class containing static functions to help procedurally build meshes
  50233. */
  50234. export class ShapeBuilder {
  50235. /**
  50236. * 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.
  50237. * * 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.
  50238. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50239. * * 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.
  50240. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50241. * * 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
  50242. * * 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
  50243. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50245. * * 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
  50246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50248. * @param name defines the name of the mesh
  50249. * @param options defines the options used to create the mesh
  50250. * @param scene defines the hosting scene
  50251. * @returns the extruded shape mesh
  50252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50254. */
  50255. static ExtrudeShape(name: string, options: {
  50256. shape: Vector3[];
  50257. path: Vector3[];
  50258. scale?: number;
  50259. rotation?: number;
  50260. cap?: number;
  50261. updatable?: boolean;
  50262. sideOrientation?: number;
  50263. frontUVs?: Vector4;
  50264. backUVs?: Vector4;
  50265. instance?: Mesh;
  50266. invertUV?: boolean;
  50267. }, scene?: Nullable<Scene>): Mesh;
  50268. /**
  50269. * Creates an custom extruded shape mesh.
  50270. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50271. * * 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.
  50272. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50273. * * 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
  50274. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50275. * * 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
  50276. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50277. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50278. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50279. * * 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
  50280. * * 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
  50281. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50283. * * 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
  50284. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50286. * @param name defines the name of the mesh
  50287. * @param options defines the options used to create the mesh
  50288. * @param scene defines the hosting scene
  50289. * @returns the custom extruded shape mesh
  50290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50293. */
  50294. static ExtrudeShapeCustom(name: string, options: {
  50295. shape: Vector3[];
  50296. path: Vector3[];
  50297. scaleFunction?: any;
  50298. rotationFunction?: any;
  50299. ribbonCloseArray?: boolean;
  50300. ribbonClosePath?: boolean;
  50301. cap?: number;
  50302. updatable?: boolean;
  50303. sideOrientation?: number;
  50304. frontUVs?: Vector4;
  50305. backUVs?: Vector4;
  50306. instance?: Mesh;
  50307. invertUV?: boolean;
  50308. }, scene?: Nullable<Scene>): Mesh;
  50309. private static _ExtrudeShapeGeneric;
  50310. }
  50311. }
  50312. declare module BABYLON {
  50313. /**
  50314. * AmmoJS Physics plugin
  50315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50316. * @see https://github.com/kripken/ammo.js/
  50317. */
  50318. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50319. private _useDeltaForWorldStep;
  50320. /**
  50321. * Reference to the Ammo library
  50322. */
  50323. bjsAMMO: any;
  50324. /**
  50325. * Created ammoJS world which physics bodies are added to
  50326. */
  50327. world: any;
  50328. /**
  50329. * Name of the plugin
  50330. */
  50331. name: string;
  50332. private _timeStep;
  50333. private _fixedTimeStep;
  50334. private _maxSteps;
  50335. private _tmpQuaternion;
  50336. private _tmpAmmoTransform;
  50337. private _tmpAmmoQuaternion;
  50338. private _tmpAmmoConcreteContactResultCallback;
  50339. private _collisionConfiguration;
  50340. private _dispatcher;
  50341. private _overlappingPairCache;
  50342. private _solver;
  50343. private _softBodySolver;
  50344. private _tmpAmmoVectorA;
  50345. private _tmpAmmoVectorB;
  50346. private _tmpAmmoVectorC;
  50347. private _tmpAmmoVectorD;
  50348. private _tmpContactCallbackResult;
  50349. private _tmpAmmoVectorRCA;
  50350. private _tmpAmmoVectorRCB;
  50351. private _raycastResult;
  50352. private static readonly DISABLE_COLLISION_FLAG;
  50353. private static readonly KINEMATIC_FLAG;
  50354. private static readonly DISABLE_DEACTIVATION_FLAG;
  50355. /**
  50356. * Initializes the ammoJS plugin
  50357. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50358. * @param ammoInjection can be used to inject your own ammo reference
  50359. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50360. */
  50361. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50362. /**
  50363. * Sets the gravity of the physics world (m/(s^2))
  50364. * @param gravity Gravity to set
  50365. */
  50366. setGravity(gravity: Vector3): void;
  50367. /**
  50368. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50369. * @param timeStep timestep to use in seconds
  50370. */
  50371. setTimeStep(timeStep: number): void;
  50372. /**
  50373. * 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)
  50374. * @param fixedTimeStep fixedTimeStep to use in seconds
  50375. */
  50376. setFixedTimeStep(fixedTimeStep: number): void;
  50377. /**
  50378. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50379. * @param maxSteps the maximum number of steps by the physics engine per frame
  50380. */
  50381. setMaxSteps(maxSteps: number): void;
  50382. /**
  50383. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50384. * @returns the current timestep in seconds
  50385. */
  50386. getTimeStep(): number;
  50387. private _isImpostorInContact;
  50388. private _isImpostorPairInContact;
  50389. private _stepSimulation;
  50390. /**
  50391. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50392. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50393. * After the step the babylon meshes are set to the position of the physics imposters
  50394. * @param delta amount of time to step forward
  50395. * @param impostors array of imposters to update before/after the step
  50396. */
  50397. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50398. /**
  50399. * Update babylon mesh to match physics world object
  50400. * @param impostor imposter to match
  50401. */
  50402. private _afterSoftStep;
  50403. /**
  50404. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50405. * @param impostor imposter to match
  50406. */
  50407. private _ropeStep;
  50408. /**
  50409. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50410. * @param impostor imposter to match
  50411. */
  50412. private _softbodyOrClothStep;
  50413. private _tmpVector;
  50414. private _tmpMatrix;
  50415. /**
  50416. * Applies an impulse on the imposter
  50417. * @param impostor imposter to apply impulse to
  50418. * @param force amount of force to be applied to the imposter
  50419. * @param contactPoint the location to apply the impulse on the imposter
  50420. */
  50421. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50422. /**
  50423. * Applies a force on the imposter
  50424. * @param impostor imposter to apply force
  50425. * @param force amount of force to be applied to the imposter
  50426. * @param contactPoint the location to apply the force on the imposter
  50427. */
  50428. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50429. /**
  50430. * Creates a physics body using the plugin
  50431. * @param impostor the imposter to create the physics body on
  50432. */
  50433. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50434. /**
  50435. * Removes the physics body from the imposter and disposes of the body's memory
  50436. * @param impostor imposter to remove the physics body from
  50437. */
  50438. removePhysicsBody(impostor: PhysicsImpostor): void;
  50439. /**
  50440. * Generates a joint
  50441. * @param impostorJoint the imposter joint to create the joint with
  50442. */
  50443. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50444. /**
  50445. * Removes a joint
  50446. * @param impostorJoint the imposter joint to remove the joint from
  50447. */
  50448. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50449. private _addMeshVerts;
  50450. /**
  50451. * Initialise the soft body vertices to match its object's (mesh) vertices
  50452. * Softbody vertices (nodes) are in world space and to match this
  50453. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50454. * @param impostor to create the softbody for
  50455. */
  50456. private _softVertexData;
  50457. /**
  50458. * Create an impostor's soft body
  50459. * @param impostor to create the softbody for
  50460. */
  50461. private _createSoftbody;
  50462. /**
  50463. * Create cloth for an impostor
  50464. * @param impostor to create the softbody for
  50465. */
  50466. private _createCloth;
  50467. /**
  50468. * Create rope for an impostor
  50469. * @param impostor to create the softbody for
  50470. */
  50471. private _createRope;
  50472. private _addHullVerts;
  50473. private _createShape;
  50474. /**
  50475. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50476. * @param impostor imposter containing the physics body and babylon object
  50477. */
  50478. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50479. /**
  50480. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50481. * @param impostor imposter containing the physics body and babylon object
  50482. * @param newPosition new position
  50483. * @param newRotation new rotation
  50484. */
  50485. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50486. /**
  50487. * If this plugin is supported
  50488. * @returns true if its supported
  50489. */
  50490. isSupported(): boolean;
  50491. /**
  50492. * Sets the linear velocity of the physics body
  50493. * @param impostor imposter to set the velocity on
  50494. * @param velocity velocity to set
  50495. */
  50496. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50497. /**
  50498. * Sets the angular velocity of the physics body
  50499. * @param impostor imposter to set the velocity on
  50500. * @param velocity velocity to set
  50501. */
  50502. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50503. /**
  50504. * gets the linear velocity
  50505. * @param impostor imposter to get linear velocity from
  50506. * @returns linear velocity
  50507. */
  50508. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50509. /**
  50510. * gets the angular velocity
  50511. * @param impostor imposter to get angular velocity from
  50512. * @returns angular velocity
  50513. */
  50514. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50515. /**
  50516. * Sets the mass of physics body
  50517. * @param impostor imposter to set the mass on
  50518. * @param mass mass to set
  50519. */
  50520. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50521. /**
  50522. * Gets the mass of the physics body
  50523. * @param impostor imposter to get the mass from
  50524. * @returns mass
  50525. */
  50526. getBodyMass(impostor: PhysicsImpostor): number;
  50527. /**
  50528. * Gets friction of the impostor
  50529. * @param impostor impostor to get friction from
  50530. * @returns friction value
  50531. */
  50532. getBodyFriction(impostor: PhysicsImpostor): number;
  50533. /**
  50534. * Sets friction of the impostor
  50535. * @param impostor impostor to set friction on
  50536. * @param friction friction value
  50537. */
  50538. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50539. /**
  50540. * Gets restitution of the impostor
  50541. * @param impostor impostor to get restitution from
  50542. * @returns restitution value
  50543. */
  50544. getBodyRestitution(impostor: PhysicsImpostor): number;
  50545. /**
  50546. * Sets resitution of the impostor
  50547. * @param impostor impostor to set resitution on
  50548. * @param restitution resitution value
  50549. */
  50550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50551. /**
  50552. * Gets pressure inside the impostor
  50553. * @param impostor impostor to get pressure from
  50554. * @returns pressure value
  50555. */
  50556. getBodyPressure(impostor: PhysicsImpostor): number;
  50557. /**
  50558. * Sets pressure inside a soft body impostor
  50559. * Cloth and rope must remain 0 pressure
  50560. * @param impostor impostor to set pressure on
  50561. * @param pressure pressure value
  50562. */
  50563. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50564. /**
  50565. * Gets stiffness of the impostor
  50566. * @param impostor impostor to get stiffness from
  50567. * @returns pressure value
  50568. */
  50569. getBodyStiffness(impostor: PhysicsImpostor): number;
  50570. /**
  50571. * Sets stiffness of the impostor
  50572. * @param impostor impostor to set stiffness on
  50573. * @param stiffness stiffness value from 0 to 1
  50574. */
  50575. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50576. /**
  50577. * Gets velocityIterations of the impostor
  50578. * @param impostor impostor to get velocity iterations from
  50579. * @returns velocityIterations value
  50580. */
  50581. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50582. /**
  50583. * Sets velocityIterations of the impostor
  50584. * @param impostor impostor to set velocity iterations on
  50585. * @param velocityIterations velocityIterations value
  50586. */
  50587. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50588. /**
  50589. * Gets positionIterations of the impostor
  50590. * @param impostor impostor to get position iterations from
  50591. * @returns positionIterations value
  50592. */
  50593. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50594. /**
  50595. * Sets positionIterations of the impostor
  50596. * @param impostor impostor to set position on
  50597. * @param positionIterations positionIterations value
  50598. */
  50599. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50600. /**
  50601. * Append an anchor to a cloth object
  50602. * @param impostor is the cloth impostor to add anchor to
  50603. * @param otherImpostor is the rigid impostor to anchor to
  50604. * @param width ratio across width from 0 to 1
  50605. * @param height ratio up height from 0 to 1
  50606. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50607. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50608. */
  50609. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50610. /**
  50611. * Append an hook to a rope object
  50612. * @param impostor is the rope impostor to add hook to
  50613. * @param otherImpostor is the rigid impostor to hook to
  50614. * @param length ratio along the rope from 0 to 1
  50615. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50616. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50617. */
  50618. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50619. /**
  50620. * Sleeps the physics body and stops it from being active
  50621. * @param impostor impostor to sleep
  50622. */
  50623. sleepBody(impostor: PhysicsImpostor): void;
  50624. /**
  50625. * Activates the physics body
  50626. * @param impostor impostor to activate
  50627. */
  50628. wakeUpBody(impostor: PhysicsImpostor): void;
  50629. /**
  50630. * Updates the distance parameters of the joint
  50631. * @param joint joint to update
  50632. * @param maxDistance maximum distance of the joint
  50633. * @param minDistance minimum distance of the joint
  50634. */
  50635. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50636. /**
  50637. * Sets a motor on the joint
  50638. * @param joint joint to set motor on
  50639. * @param speed speed of the motor
  50640. * @param maxForce maximum force of the motor
  50641. * @param motorIndex index of the motor
  50642. */
  50643. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50644. /**
  50645. * Sets the motors limit
  50646. * @param joint joint to set limit on
  50647. * @param upperLimit upper limit
  50648. * @param lowerLimit lower limit
  50649. */
  50650. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50651. /**
  50652. * Syncs the position and rotation of a mesh with the impostor
  50653. * @param mesh mesh to sync
  50654. * @param impostor impostor to update the mesh with
  50655. */
  50656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50657. /**
  50658. * Gets the radius of the impostor
  50659. * @param impostor impostor to get radius from
  50660. * @returns the radius
  50661. */
  50662. getRadius(impostor: PhysicsImpostor): number;
  50663. /**
  50664. * Gets the box size of the impostor
  50665. * @param impostor impostor to get box size from
  50666. * @param result the resulting box size
  50667. */
  50668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50669. /**
  50670. * Disposes of the impostor
  50671. */
  50672. dispose(): void;
  50673. /**
  50674. * Does a raycast in the physics world
  50675. * @param from when should the ray start?
  50676. * @param to when should the ray end?
  50677. * @returns PhysicsRaycastResult
  50678. */
  50679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50680. }
  50681. }
  50682. declare module BABYLON {
  50683. interface AbstractScene {
  50684. /**
  50685. * The list of reflection probes added to the scene
  50686. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50687. */
  50688. reflectionProbes: Array<ReflectionProbe>;
  50689. /**
  50690. * Removes the given reflection probe from this scene.
  50691. * @param toRemove The reflection probe to remove
  50692. * @returns The index of the removed reflection probe
  50693. */
  50694. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50695. /**
  50696. * Adds the given reflection probe to this scene.
  50697. * @param newReflectionProbe The reflection probe to add
  50698. */
  50699. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50700. }
  50701. /**
  50702. * Class used to generate realtime reflection / refraction cube textures
  50703. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50704. */
  50705. export class ReflectionProbe {
  50706. /** defines the name of the probe */
  50707. name: string;
  50708. private _scene;
  50709. private _renderTargetTexture;
  50710. private _projectionMatrix;
  50711. private _viewMatrix;
  50712. private _target;
  50713. private _add;
  50714. private _attachedMesh;
  50715. private _invertYAxis;
  50716. /** Gets or sets probe position (center of the cube map) */
  50717. position: Vector3;
  50718. /**
  50719. * Creates a new reflection probe
  50720. * @param name defines the name of the probe
  50721. * @param size defines the texture resolution (for each face)
  50722. * @param scene defines the hosting scene
  50723. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50724. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50725. */
  50726. constructor(
  50727. /** defines the name of the probe */
  50728. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50729. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50730. samples: number;
  50731. /** Gets or sets the refresh rate to use (on every frame by default) */
  50732. refreshRate: number;
  50733. /**
  50734. * Gets the hosting scene
  50735. * @returns a Scene
  50736. */
  50737. getScene(): Scene;
  50738. /** Gets the internal CubeTexture used to render to */
  50739. readonly cubeTexture: RenderTargetTexture;
  50740. /** Gets the list of meshes to render */
  50741. readonly renderList: Nullable<AbstractMesh[]>;
  50742. /**
  50743. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50744. * @param mesh defines the mesh to attach to
  50745. */
  50746. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50747. /**
  50748. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50749. * @param renderingGroupId The rendering group id corresponding to its index
  50750. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50751. */
  50752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50753. /**
  50754. * Clean all associated resources
  50755. */
  50756. dispose(): void;
  50757. /**
  50758. * Converts the reflection probe information to a readable string for debug purpose.
  50759. * @param fullDetails Supports for multiple levels of logging within scene loading
  50760. * @returns the human readable reflection probe info
  50761. */
  50762. toString(fullDetails?: boolean): string;
  50763. /**
  50764. * Get the class name of the relfection probe.
  50765. * @returns "ReflectionProbe"
  50766. */
  50767. getClassName(): string;
  50768. /**
  50769. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50770. * @returns The JSON representation of the texture
  50771. */
  50772. serialize(): any;
  50773. /**
  50774. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50775. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50776. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50777. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50778. * @returns The parsed reflection probe if successful
  50779. */
  50780. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50781. }
  50782. }
  50783. declare module BABYLON {
  50784. /** @hidden */
  50785. export var _BabylonLoaderRegistered: boolean;
  50786. }
  50787. declare module BABYLON {
  50788. /**
  50789. * The Physically based simple base material of BJS.
  50790. *
  50791. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50792. * It is used as the base class for both the specGloss and metalRough conventions.
  50793. */
  50794. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50795. /**
  50796. * Number of Simultaneous lights allowed on the material.
  50797. */
  50798. maxSimultaneousLights: number;
  50799. /**
  50800. * If sets to true, disables all the lights affecting the material.
  50801. */
  50802. disableLighting: boolean;
  50803. /**
  50804. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50805. */
  50806. environmentTexture: BaseTexture;
  50807. /**
  50808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50809. */
  50810. invertNormalMapX: boolean;
  50811. /**
  50812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50813. */
  50814. invertNormalMapY: boolean;
  50815. /**
  50816. * Normal map used in the model.
  50817. */
  50818. normalTexture: BaseTexture;
  50819. /**
  50820. * Emissivie color used to self-illuminate the model.
  50821. */
  50822. emissiveColor: Color3;
  50823. /**
  50824. * Emissivie texture used to self-illuminate the model.
  50825. */
  50826. emissiveTexture: BaseTexture;
  50827. /**
  50828. * Occlusion Channel Strenght.
  50829. */
  50830. occlusionStrength: number;
  50831. /**
  50832. * Occlusion Texture of the material (adding extra occlusion effects).
  50833. */
  50834. occlusionTexture: BaseTexture;
  50835. /**
  50836. * Defines the alpha limits in alpha test mode.
  50837. */
  50838. alphaCutOff: number;
  50839. /**
  50840. * Gets the current double sided mode.
  50841. */
  50842. /**
  50843. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50844. */
  50845. doubleSided: boolean;
  50846. /**
  50847. * Stores the pre-calculated light information of a mesh in a texture.
  50848. */
  50849. lightmapTexture: BaseTexture;
  50850. /**
  50851. * If true, the light map contains occlusion information instead of lighting info.
  50852. */
  50853. useLightmapAsShadowmap: boolean;
  50854. /**
  50855. * Instantiates a new PBRMaterial instance.
  50856. *
  50857. * @param name The material name
  50858. * @param scene The scene the material will be use in.
  50859. */
  50860. constructor(name: string, scene: Scene);
  50861. getClassName(): string;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /**
  50866. * The PBR material of BJS following the metal roughness convention.
  50867. *
  50868. * This fits to the PBR convention in the GLTF definition:
  50869. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50870. */
  50871. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50872. /**
  50873. * The base color has two different interpretations depending on the value of metalness.
  50874. * When the material is a metal, the base color is the specific measured reflectance value
  50875. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50876. * of the material.
  50877. */
  50878. baseColor: Color3;
  50879. /**
  50880. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50881. * well as opacity information in the alpha channel.
  50882. */
  50883. baseTexture: BaseTexture;
  50884. /**
  50885. * Specifies the metallic scalar value of the material.
  50886. * Can also be used to scale the metalness values of the metallic texture.
  50887. */
  50888. metallic: number;
  50889. /**
  50890. * Specifies the roughness scalar value of the material.
  50891. * Can also be used to scale the roughness values of the metallic texture.
  50892. */
  50893. roughness: number;
  50894. /**
  50895. * Texture containing both the metallic value in the B channel and the
  50896. * roughness value in the G channel to keep better precision.
  50897. */
  50898. metallicRoughnessTexture: BaseTexture;
  50899. /**
  50900. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50901. *
  50902. * @param name The material name
  50903. * @param scene The scene the material will be use in.
  50904. */
  50905. constructor(name: string, scene: Scene);
  50906. /**
  50907. * Return the currrent class name of the material.
  50908. */
  50909. getClassName(): string;
  50910. /**
  50911. * Makes a duplicate of the current material.
  50912. * @param name - name to use for the new material.
  50913. */
  50914. clone(name: string): PBRMetallicRoughnessMaterial;
  50915. /**
  50916. * Serialize the material to a parsable JSON object.
  50917. */
  50918. serialize(): any;
  50919. /**
  50920. * Parses a JSON object correponding to the serialize function.
  50921. */
  50922. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50923. }
  50924. }
  50925. declare module BABYLON {
  50926. /**
  50927. * The PBR material of BJS following the specular glossiness convention.
  50928. *
  50929. * This fits to the PBR convention in the GLTF definition:
  50930. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50931. */
  50932. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50933. /**
  50934. * Specifies the diffuse color of the material.
  50935. */
  50936. diffuseColor: Color3;
  50937. /**
  50938. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50939. * channel.
  50940. */
  50941. diffuseTexture: BaseTexture;
  50942. /**
  50943. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50944. */
  50945. specularColor: Color3;
  50946. /**
  50947. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50948. */
  50949. glossiness: number;
  50950. /**
  50951. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50952. */
  50953. specularGlossinessTexture: BaseTexture;
  50954. /**
  50955. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50956. *
  50957. * @param name The material name
  50958. * @param scene The scene the material will be use in.
  50959. */
  50960. constructor(name: string, scene: Scene);
  50961. /**
  50962. * Return the currrent class name of the material.
  50963. */
  50964. getClassName(): string;
  50965. /**
  50966. * Makes a duplicate of the current material.
  50967. * @param name - name to use for the new material.
  50968. */
  50969. clone(name: string): PBRSpecularGlossinessMaterial;
  50970. /**
  50971. * Serialize the material to a parsable JSON object.
  50972. */
  50973. serialize(): any;
  50974. /**
  50975. * Parses a JSON object correponding to the serialize function.
  50976. */
  50977. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50978. }
  50979. }
  50980. declare module BABYLON {
  50981. /**
  50982. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50983. * It can help converting any input color in a desired output one. This can then be used to create effects
  50984. * from sepia, black and white to sixties or futuristic rendering...
  50985. *
  50986. * The only supported format is currently 3dl.
  50987. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50988. */
  50989. export class ColorGradingTexture extends BaseTexture {
  50990. /**
  50991. * The current texture matrix. (will always be identity in color grading texture)
  50992. */
  50993. private _textureMatrix;
  50994. /**
  50995. * The texture URL.
  50996. */
  50997. url: string;
  50998. /**
  50999. * Empty line regex stored for GC.
  51000. */
  51001. private static _noneEmptyLineRegex;
  51002. private _engine;
  51003. /**
  51004. * Instantiates a ColorGradingTexture from the following parameters.
  51005. *
  51006. * @param url The location of the color gradind data (currently only supporting 3dl)
  51007. * @param scene The scene the texture will be used in
  51008. */
  51009. constructor(url: string, scene: Scene);
  51010. /**
  51011. * Returns the texture matrix used in most of the material.
  51012. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51013. */
  51014. getTextureMatrix(): Matrix;
  51015. /**
  51016. * Occurs when the file being loaded is a .3dl LUT file.
  51017. */
  51018. private load3dlTexture;
  51019. /**
  51020. * Starts the loading process of the texture.
  51021. */
  51022. private loadTexture;
  51023. /**
  51024. * Clones the color gradind texture.
  51025. */
  51026. clone(): ColorGradingTexture;
  51027. /**
  51028. * Called during delayed load for textures.
  51029. */
  51030. delayLoad(): void;
  51031. /**
  51032. * Parses a color grading texture serialized by Babylon.
  51033. * @param parsedTexture The texture information being parsedTexture
  51034. * @param scene The scene to load the texture in
  51035. * @param rootUrl The root url of the data assets to load
  51036. * @return A color gradind texture
  51037. */
  51038. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51039. /**
  51040. * Serializes the LUT texture to json format.
  51041. */
  51042. serialize(): any;
  51043. }
  51044. }
  51045. declare module BABYLON {
  51046. /**
  51047. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51048. */
  51049. export class EquiRectangularCubeTexture extends BaseTexture {
  51050. /** The six faces of the cube. */
  51051. private static _FacesMapping;
  51052. private _noMipmap;
  51053. private _onLoad;
  51054. private _onError;
  51055. /** The size of the cubemap. */
  51056. private _size;
  51057. /** The buffer of the image. */
  51058. private _buffer;
  51059. /** The width of the input image. */
  51060. private _width;
  51061. /** The height of the input image. */
  51062. private _height;
  51063. /** The URL to the image. */
  51064. url: string;
  51065. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51066. coordinatesMode: number;
  51067. /**
  51068. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51069. * @param url The location of the image
  51070. * @param scene The scene the texture will be used in
  51071. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51072. * @param noMipmap Forces to not generate the mipmap if true
  51073. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51074. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51075. * @param onLoad — defines a callback called when texture is loaded
  51076. * @param onError — defines a callback called if there is an error
  51077. */
  51078. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51079. /**
  51080. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51081. */
  51082. private loadImage;
  51083. /**
  51084. * Convert the image buffer into a cubemap and create a CubeTexture.
  51085. */
  51086. private loadTexture;
  51087. /**
  51088. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51089. * @param buffer The ArrayBuffer that should be converted.
  51090. * @returns The buffer as Float32Array.
  51091. */
  51092. private getFloat32ArrayFromArrayBuffer;
  51093. /**
  51094. * Get the current class name of the texture useful for serialization or dynamic coding.
  51095. * @returns "EquiRectangularCubeTexture"
  51096. */
  51097. getClassName(): string;
  51098. /**
  51099. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51100. * @returns A clone of the current EquiRectangularCubeTexture.
  51101. */
  51102. clone(): EquiRectangularCubeTexture;
  51103. }
  51104. }
  51105. declare module BABYLON {
  51106. /**
  51107. * Based on jsTGALoader - Javascript loader for TGA file
  51108. * By Vincent Thibault
  51109. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51110. */
  51111. export class TGATools {
  51112. private static _TYPE_INDEXED;
  51113. private static _TYPE_RGB;
  51114. private static _TYPE_GREY;
  51115. private static _TYPE_RLE_INDEXED;
  51116. private static _TYPE_RLE_RGB;
  51117. private static _TYPE_RLE_GREY;
  51118. private static _ORIGIN_MASK;
  51119. private static _ORIGIN_SHIFT;
  51120. private static _ORIGIN_BL;
  51121. private static _ORIGIN_BR;
  51122. private static _ORIGIN_UL;
  51123. private static _ORIGIN_UR;
  51124. /**
  51125. * Gets the header of a TGA file
  51126. * @param data defines the TGA data
  51127. * @returns the header
  51128. */
  51129. static GetTGAHeader(data: Uint8Array): any;
  51130. /**
  51131. * Uploads TGA content to a Babylon Texture
  51132. * @hidden
  51133. */
  51134. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51135. /** @hidden */
  51136. 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;
  51137. /** @hidden */
  51138. 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;
  51139. /** @hidden */
  51140. 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;
  51141. /** @hidden */
  51142. 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;
  51143. /** @hidden */
  51144. 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;
  51145. /** @hidden */
  51146. 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;
  51147. }
  51148. }
  51149. declare module BABYLON {
  51150. /**
  51151. * Implementation of the TGA Texture Loader.
  51152. * @hidden
  51153. */
  51154. export class _TGATextureLoader implements IInternalTextureLoader {
  51155. /**
  51156. * Defines wether the loader supports cascade loading the different faces.
  51157. */
  51158. readonly supportCascades: boolean;
  51159. /**
  51160. * This returns if the loader support the current file information.
  51161. * @param extension defines the file extension of the file being loaded
  51162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51163. * @param fallback defines the fallback internal texture if any
  51164. * @param isBase64 defines whether the texture is encoded as a base64
  51165. * @param isBuffer defines whether the texture data are stored as a buffer
  51166. * @returns true if the loader can load the specified file
  51167. */
  51168. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51169. /**
  51170. * Transform the url before loading if required.
  51171. * @param rootUrl the url of the texture
  51172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51173. * @returns the transformed texture
  51174. */
  51175. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51176. /**
  51177. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51178. * @param rootUrl the url of the texture
  51179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51180. * @returns the fallback texture
  51181. */
  51182. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51183. /**
  51184. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51185. * @param data contains the texture data
  51186. * @param texture defines the BabylonJS internal texture
  51187. * @param createPolynomials will be true if polynomials have been requested
  51188. * @param onLoad defines the callback to trigger once the texture is ready
  51189. * @param onError defines the callback to trigger in case of error
  51190. */
  51191. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51192. /**
  51193. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51194. * @param data contains the texture data
  51195. * @param texture defines the BabylonJS internal texture
  51196. * @param callback defines the method to call once ready to upload
  51197. */
  51198. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51199. }
  51200. }
  51201. declare module BABYLON {
  51202. /**
  51203. * Info about the .basis files
  51204. */
  51205. class BasisFileInfo {
  51206. /**
  51207. * If the file has alpha
  51208. */
  51209. hasAlpha: boolean;
  51210. /**
  51211. * Info about each image of the basis file
  51212. */
  51213. images: Array<{
  51214. levels: Array<{
  51215. width: number;
  51216. height: number;
  51217. transcodedPixels: ArrayBufferView;
  51218. }>;
  51219. }>;
  51220. }
  51221. /**
  51222. * Result of transcoding a basis file
  51223. */
  51224. class TranscodeResult {
  51225. /**
  51226. * Info about the .basis file
  51227. */
  51228. fileInfo: BasisFileInfo;
  51229. /**
  51230. * Format to use when loading the file
  51231. */
  51232. format: number;
  51233. }
  51234. /**
  51235. * Configuration options for the Basis transcoder
  51236. */
  51237. export class BasisTranscodeConfiguration {
  51238. /**
  51239. * Supported compression formats used to determine the supported output format of the transcoder
  51240. */
  51241. supportedCompressionFormats?: {
  51242. /**
  51243. * etc1 compression format
  51244. */
  51245. etc1?: boolean;
  51246. /**
  51247. * s3tc compression format
  51248. */
  51249. s3tc?: boolean;
  51250. /**
  51251. * pvrtc compression format
  51252. */
  51253. pvrtc?: boolean;
  51254. /**
  51255. * etc2 compression format
  51256. */
  51257. etc2?: boolean;
  51258. };
  51259. /**
  51260. * If mipmap levels should be loaded for transcoded images (Default: true)
  51261. */
  51262. loadMipmapLevels?: boolean;
  51263. /**
  51264. * Index of a single image to load (Default: all images)
  51265. */
  51266. loadSingleImage?: number;
  51267. }
  51268. /**
  51269. * Used to load .Basis files
  51270. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51271. */
  51272. export class BasisTools {
  51273. private static _IgnoreSupportedFormats;
  51274. /**
  51275. * URL to use when loading the basis transcoder
  51276. */
  51277. static JSModuleURL: string;
  51278. /**
  51279. * URL to use when loading the wasm module for the transcoder
  51280. */
  51281. static WasmModuleURL: string;
  51282. /**
  51283. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51284. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51285. * @returns internal format corresponding to the Basis format
  51286. */
  51287. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51288. private static _WorkerPromise;
  51289. private static _Worker;
  51290. private static _actionId;
  51291. private static _CreateWorkerAsync;
  51292. /**
  51293. * Transcodes a loaded image file to compressed pixel data
  51294. * @param imageData image data to transcode
  51295. * @param config configuration options for the transcoding
  51296. * @returns a promise resulting in the transcoded image
  51297. */
  51298. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51299. /**
  51300. * Loads a texture from the transcode result
  51301. * @param texture texture load to
  51302. * @param transcodeResult the result of transcoding the basis file to load from
  51303. */
  51304. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51305. }
  51306. }
  51307. declare module BABYLON {
  51308. /**
  51309. * Loader for .basis file format
  51310. */
  51311. export class _BasisTextureLoader implements IInternalTextureLoader {
  51312. /**
  51313. * Defines whether the loader supports cascade loading the different faces.
  51314. */
  51315. readonly supportCascades: boolean;
  51316. /**
  51317. * This returns if the loader support the current file information.
  51318. * @param extension defines the file extension of the file being loaded
  51319. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51320. * @param fallback defines the fallback internal texture if any
  51321. * @param isBase64 defines whether the texture is encoded as a base64
  51322. * @param isBuffer defines whether the texture data are stored as a buffer
  51323. * @returns true if the loader can load the specified file
  51324. */
  51325. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51326. /**
  51327. * Transform the url before loading if required.
  51328. * @param rootUrl the url of the texture
  51329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51330. * @returns the transformed texture
  51331. */
  51332. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51333. /**
  51334. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51335. * @param rootUrl the url of the texture
  51336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51337. * @returns the fallback texture
  51338. */
  51339. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51340. /**
  51341. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51342. * @param data contains the texture data
  51343. * @param texture defines the BabylonJS internal texture
  51344. * @param createPolynomials will be true if polynomials have been requested
  51345. * @param onLoad defines the callback to trigger once the texture is ready
  51346. * @param onError defines the callback to trigger in case of error
  51347. */
  51348. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51349. /**
  51350. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51351. * @param data contains the texture data
  51352. * @param texture defines the BabylonJS internal texture
  51353. * @param callback defines the method to call once ready to upload
  51354. */
  51355. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51356. }
  51357. }
  51358. declare module BABYLON {
  51359. /**
  51360. * 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.
  51361. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51363. */
  51364. export class CustomProceduralTexture extends ProceduralTexture {
  51365. private _animate;
  51366. private _time;
  51367. private _config;
  51368. private _texturePath;
  51369. /**
  51370. * Instantiates a new Custom Procedural Texture.
  51371. * 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.
  51372. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51373. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51374. * @param name Define the name of the texture
  51375. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51376. * @param size Define the size of the texture to create
  51377. * @param scene Define the scene the texture belongs to
  51378. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51379. * @param generateMipMaps Define if the texture should creates mip maps or not
  51380. */
  51381. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51382. private _loadJson;
  51383. /**
  51384. * Is the texture ready to be used ? (rendered at least once)
  51385. * @returns true if ready, otherwise, false.
  51386. */
  51387. isReady(): boolean;
  51388. /**
  51389. * Render the texture to its associated render target.
  51390. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51391. */
  51392. render(useCameraPostProcess?: boolean): void;
  51393. /**
  51394. * Update the list of dependant textures samplers in the shader.
  51395. */
  51396. updateTextures(): void;
  51397. /**
  51398. * Update the uniform values of the procedural texture in the shader.
  51399. */
  51400. updateShaderUniforms(): void;
  51401. /**
  51402. * Define if the texture animates or not.
  51403. */
  51404. animate: boolean;
  51405. }
  51406. }
  51407. declare module BABYLON {
  51408. /** @hidden */
  51409. export var noisePixelShader: {
  51410. name: string;
  51411. shader: string;
  51412. };
  51413. }
  51414. declare module BABYLON {
  51415. /**
  51416. * Class used to generate noise procedural textures
  51417. */
  51418. export class NoiseProceduralTexture extends ProceduralTexture {
  51419. private _time;
  51420. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51421. brightness: number;
  51422. /** Defines the number of octaves to process */
  51423. octaves: number;
  51424. /** Defines the level of persistence (0.8 by default) */
  51425. persistence: number;
  51426. /** Gets or sets animation speed factor (default is 1) */
  51427. animationSpeedFactor: number;
  51428. /**
  51429. * Creates a new NoiseProceduralTexture
  51430. * @param name defines the name fo the texture
  51431. * @param size defines the size of the texture (default is 256)
  51432. * @param scene defines the hosting scene
  51433. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51434. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51435. */
  51436. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51437. private _updateShaderUniforms;
  51438. protected _getDefines(): string;
  51439. /** Generate the current state of the procedural texture */
  51440. render(useCameraPostProcess?: boolean): void;
  51441. /**
  51442. * Serializes this noise procedural texture
  51443. * @returns a serialized noise procedural texture object
  51444. */
  51445. serialize(): any;
  51446. /**
  51447. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51448. * @param parsedTexture defines parsed texture data
  51449. * @param scene defines the current scene
  51450. * @param rootUrl defines the root URL containing noise procedural texture information
  51451. * @returns a parsed NoiseProceduralTexture
  51452. */
  51453. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51454. }
  51455. }
  51456. declare module BABYLON {
  51457. /**
  51458. * Raw cube texture where the raw buffers are passed in
  51459. */
  51460. export class RawCubeTexture extends CubeTexture {
  51461. /**
  51462. * Creates a cube texture where the raw buffers are passed in.
  51463. * @param scene defines the scene the texture is attached to
  51464. * @param data defines the array of data to use to create each face
  51465. * @param size defines the size of the textures
  51466. * @param format defines the format of the data
  51467. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51468. * @param generateMipMaps defines if the engine should generate the mip levels
  51469. * @param invertY defines if data must be stored with Y axis inverted
  51470. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51471. * @param compression defines the compression used (null by default)
  51472. */
  51473. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51474. /**
  51475. * Updates the raw cube texture.
  51476. * @param data defines the data to store
  51477. * @param format defines the data format
  51478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51479. * @param invertY defines if data must be stored with Y axis inverted
  51480. * @param compression defines the compression used (null by default)
  51481. * @param level defines which level of the texture to update
  51482. */
  51483. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51484. /**
  51485. * Updates a raw cube texture with RGBD encoded data.
  51486. * @param data defines the array of data [mipmap][face] to use to create each face
  51487. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51488. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51489. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51490. * @returns a promsie that resolves when the operation is complete
  51491. */
  51492. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51493. /**
  51494. * Clones the raw cube texture.
  51495. * @return a new cube texture
  51496. */
  51497. clone(): CubeTexture;
  51498. /** @hidden */
  51499. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51500. }
  51501. }
  51502. declare module BABYLON {
  51503. /**
  51504. * Class used to store 3D textures containing user data
  51505. */
  51506. export class RawTexture3D extends Texture {
  51507. /** Gets or sets the texture format to use */
  51508. format: number;
  51509. private _engine;
  51510. /**
  51511. * Create a new RawTexture3D
  51512. * @param data defines the data of the texture
  51513. * @param width defines the width of the texture
  51514. * @param height defines the height of the texture
  51515. * @param depth defines the depth of the texture
  51516. * @param format defines the texture format to use
  51517. * @param scene defines the hosting scene
  51518. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51519. * @param invertY defines if texture must be stored with Y axis inverted
  51520. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51521. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51522. */
  51523. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51524. /** Gets or sets the texture format to use */
  51525. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51526. /**
  51527. * Update the texture with new data
  51528. * @param data defines the data to store in the texture
  51529. */
  51530. update(data: ArrayBufferView): void;
  51531. }
  51532. }
  51533. declare module BABYLON {
  51534. /**
  51535. * Creates a refraction texture used by refraction channel of the standard material.
  51536. * It is like a mirror but to see through a material.
  51537. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51538. */
  51539. export class RefractionTexture extends RenderTargetTexture {
  51540. /**
  51541. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51542. * 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.
  51543. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51544. */
  51545. refractionPlane: Plane;
  51546. /**
  51547. * Define how deep under the surface we should see.
  51548. */
  51549. depth: number;
  51550. /**
  51551. * Creates a refraction texture used by refraction channel of the standard material.
  51552. * It is like a mirror but to see through a material.
  51553. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51554. * @param name Define the texture name
  51555. * @param size Define the size of the underlying texture
  51556. * @param scene Define the scene the refraction belongs to
  51557. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51558. */
  51559. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51560. /**
  51561. * Clone the refraction texture.
  51562. * @returns the cloned texture
  51563. */
  51564. clone(): RefractionTexture;
  51565. /**
  51566. * Serialize the texture to a JSON representation you could use in Parse later on
  51567. * @returns the serialized JSON representation
  51568. */
  51569. serialize(): any;
  51570. }
  51571. }
  51572. declare module BABYLON {
  51573. /**
  51574. * Defines the options related to the creation of an HtmlElementTexture
  51575. */
  51576. export interface IHtmlElementTextureOptions {
  51577. /**
  51578. * Defines wether mip maps should be created or not.
  51579. */
  51580. generateMipMaps?: boolean;
  51581. /**
  51582. * Defines the sampling mode of the texture.
  51583. */
  51584. samplingMode?: number;
  51585. /**
  51586. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51587. */
  51588. engine: Nullable<Engine>;
  51589. /**
  51590. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51591. */
  51592. scene: Nullable<Scene>;
  51593. }
  51594. /**
  51595. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51596. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51597. * is automatically managed.
  51598. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51599. * in your application.
  51600. *
  51601. * As the update is not automatic, you need to call them manually.
  51602. */
  51603. export class HtmlElementTexture extends BaseTexture {
  51604. /**
  51605. * The texture URL.
  51606. */
  51607. element: HTMLVideoElement | HTMLCanvasElement;
  51608. private static readonly DefaultOptions;
  51609. private _textureMatrix;
  51610. private _engine;
  51611. private _isVideo;
  51612. private _generateMipMaps;
  51613. private _samplingMode;
  51614. /**
  51615. * Instantiates a HtmlElementTexture from the following parameters.
  51616. *
  51617. * @param name Defines the name of the texture
  51618. * @param element Defines the video or canvas the texture is filled with
  51619. * @param options Defines the other none mandatory texture creation options
  51620. */
  51621. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51622. private _createInternalTexture;
  51623. /**
  51624. * Returns the texture matrix used in most of the material.
  51625. */
  51626. getTextureMatrix(): Matrix;
  51627. /**
  51628. * Updates the content of the texture.
  51629. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51630. */
  51631. update(invertY?: Nullable<boolean>): void;
  51632. }
  51633. }
  51634. declare module BABYLON {
  51635. /**
  51636. * Enum used to define the target of a block
  51637. */
  51638. export enum NodeMaterialBlockTargets {
  51639. /** Vertex shader */
  51640. Vertex = 1,
  51641. /** Fragment shader */
  51642. Fragment = 2,
  51643. /** Neutral */
  51644. Neutral = 4,
  51645. /** Vertex and Fragment */
  51646. VertexAndFragment = 3
  51647. }
  51648. }
  51649. declare module BABYLON {
  51650. /**
  51651. * Defines the kind of connection point for node based material
  51652. */
  51653. export enum NodeMaterialBlockConnectionPointTypes {
  51654. /** Float */
  51655. Float = 1,
  51656. /** Int */
  51657. Int = 2,
  51658. /** Vector2 */
  51659. Vector2 = 4,
  51660. /** Vector3 */
  51661. Vector3 = 8,
  51662. /** Vector4 */
  51663. Vector4 = 16,
  51664. /** Color3 */
  51665. Color3 = 32,
  51666. /** Color4 */
  51667. Color4 = 64,
  51668. /** Matrix */
  51669. Matrix = 128,
  51670. /** Detect type based on connection */
  51671. AutoDetect = 1024,
  51672. /** Output type that will be defined by input type */
  51673. BasedOnInput = 2048
  51674. }
  51675. }
  51676. declare module BABYLON {
  51677. /**
  51678. * Root class for all node material optimizers
  51679. */
  51680. export class NodeMaterialOptimizer {
  51681. /**
  51682. * Function used to optimize a NodeMaterial graph
  51683. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51684. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51685. */
  51686. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51687. }
  51688. }
  51689. declare module BABYLON {
  51690. /**
  51691. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51692. */
  51693. export class TransformBlock extends NodeMaterialBlock {
  51694. /**
  51695. * Defines the value to use to complement W value to transform it to a Vector4
  51696. */
  51697. complementW: number;
  51698. /**
  51699. * Defines the value to use to complement z value to transform it to a Vector4
  51700. */
  51701. complementZ: number;
  51702. /**
  51703. * Creates a new TransformBlock
  51704. * @param name defines the block name
  51705. */
  51706. constructor(name: string);
  51707. /**
  51708. * Gets the current class name
  51709. * @returns the class name
  51710. */
  51711. getClassName(): string;
  51712. /**
  51713. * Gets the vector input
  51714. */
  51715. readonly vector: NodeMaterialConnectionPoint;
  51716. /**
  51717. * Gets the output component
  51718. */
  51719. readonly output: NodeMaterialConnectionPoint;
  51720. /**
  51721. * Gets the matrix transform input
  51722. */
  51723. readonly transform: NodeMaterialConnectionPoint;
  51724. protected _buildBlock(state: NodeMaterialBuildState): this;
  51725. serialize(): any;
  51726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51727. protected _dumpPropertiesCode(): string;
  51728. }
  51729. }
  51730. declare module BABYLON {
  51731. /**
  51732. * Block used to output the vertex position
  51733. */
  51734. export class VertexOutputBlock extends NodeMaterialBlock {
  51735. /**
  51736. * Creates a new VertexOutputBlock
  51737. * @param name defines the block name
  51738. */
  51739. constructor(name: string);
  51740. /**
  51741. * Gets the current class name
  51742. * @returns the class name
  51743. */
  51744. getClassName(): string;
  51745. /**
  51746. * Gets the vector input component
  51747. */
  51748. readonly vector: NodeMaterialConnectionPoint;
  51749. protected _buildBlock(state: NodeMaterialBuildState): this;
  51750. }
  51751. }
  51752. declare module BABYLON {
  51753. /**
  51754. * Block used to output the final color
  51755. */
  51756. export class FragmentOutputBlock extends NodeMaterialBlock {
  51757. /**
  51758. * Create a new FragmentOutputBlock
  51759. * @param name defines the block name
  51760. */
  51761. constructor(name: string);
  51762. /**
  51763. * Gets the current class name
  51764. * @returns the class name
  51765. */
  51766. getClassName(): string;
  51767. /**
  51768. * Gets the rgba input component
  51769. */
  51770. readonly rgba: NodeMaterialConnectionPoint;
  51771. /**
  51772. * Gets the rgb input component
  51773. */
  51774. readonly rgb: NodeMaterialConnectionPoint;
  51775. /**
  51776. * Gets the a input component
  51777. */
  51778. readonly a: NodeMaterialConnectionPoint;
  51779. protected _buildBlock(state: NodeMaterialBuildState): this;
  51780. }
  51781. }
  51782. declare module BABYLON {
  51783. /**
  51784. * Enum used to define well known values e.g. values automatically provided by the system
  51785. */
  51786. export enum NodeMaterialWellKnownValues {
  51787. /** World */
  51788. World = 1,
  51789. /** View */
  51790. View = 2,
  51791. /** Projection */
  51792. Projection = 3,
  51793. /** ViewProjection */
  51794. ViewProjection = 4,
  51795. /** WorldView */
  51796. WorldView = 5,
  51797. /** WorldViewProjection */
  51798. WorldViewProjection = 6,
  51799. /** CameraPosition */
  51800. CameraPosition = 7,
  51801. /** Fog Color */
  51802. FogColor = 8
  51803. }
  51804. }
  51805. declare module BABYLON {
  51806. /**
  51807. * Block used to read a reflection texture from a sampler
  51808. */
  51809. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51810. private _define3DName;
  51811. private _defineCubicName;
  51812. private _defineExplicitName;
  51813. private _defineProjectionName;
  51814. private _defineLocalCubicName;
  51815. private _defineSphericalName;
  51816. private _definePlanarName;
  51817. private _defineEquirectangularName;
  51818. private _defineMirroredEquirectangularFixedName;
  51819. private _defineEquirectangularFixedName;
  51820. private _defineSkyboxName;
  51821. private _cubeSamplerName;
  51822. private _2DSamplerName;
  51823. private _positionUVWName;
  51824. private _directionWName;
  51825. private _reflectionCoordsName;
  51826. private _reflection2DCoordsName;
  51827. private _reflectionColorName;
  51828. private _reflectionMatrixName;
  51829. /**
  51830. * Gets or sets the texture associated with the node
  51831. */
  51832. texture: Nullable<BaseTexture>;
  51833. /**
  51834. * Create a new TextureBlock
  51835. * @param name defines the block name
  51836. */
  51837. constructor(name: string);
  51838. /**
  51839. * Gets the current class name
  51840. * @returns the class name
  51841. */
  51842. getClassName(): string;
  51843. /**
  51844. * Gets the world position input component
  51845. */
  51846. readonly position: NodeMaterialConnectionPoint;
  51847. /**
  51848. * Gets the world position input component
  51849. */
  51850. readonly worldPosition: NodeMaterialConnectionPoint;
  51851. /**
  51852. * Gets the world normal input component
  51853. */
  51854. readonly worldNormal: NodeMaterialConnectionPoint;
  51855. /**
  51856. * Gets the world input component
  51857. */
  51858. readonly world: NodeMaterialConnectionPoint;
  51859. /**
  51860. * Gets the camera (or eye) position component
  51861. */
  51862. readonly cameraPosition: NodeMaterialConnectionPoint;
  51863. /**
  51864. * Gets the view input component
  51865. */
  51866. readonly view: NodeMaterialConnectionPoint;
  51867. /**
  51868. * Gets the rgb output component
  51869. */
  51870. readonly rgb: NodeMaterialConnectionPoint;
  51871. /**
  51872. * Gets the r output component
  51873. */
  51874. readonly r: NodeMaterialConnectionPoint;
  51875. /**
  51876. * Gets the g output component
  51877. */
  51878. readonly g: NodeMaterialConnectionPoint;
  51879. /**
  51880. * Gets the b output component
  51881. */
  51882. readonly b: NodeMaterialConnectionPoint;
  51883. autoConfigure(): void;
  51884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51885. isReady(): boolean;
  51886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51887. private _injectVertexCode;
  51888. private _writeOutput;
  51889. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51890. serialize(): any;
  51891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51892. }
  51893. }
  51894. declare module BABYLON {
  51895. /**
  51896. * Interface used to configure the node material editor
  51897. */
  51898. export interface INodeMaterialEditorOptions {
  51899. /** Define the URl to load node editor script */
  51900. editorURL?: string;
  51901. }
  51902. /** @hidden */
  51903. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  51904. /** BONES */
  51905. NUM_BONE_INFLUENCERS: number;
  51906. BonesPerMesh: number;
  51907. BONETEXTURE: boolean;
  51908. /** MORPH TARGETS */
  51909. MORPHTARGETS: boolean;
  51910. MORPHTARGETS_NORMAL: boolean;
  51911. MORPHTARGETS_TANGENT: boolean;
  51912. MORPHTARGETS_UV: boolean;
  51913. NUM_MORPH_INFLUENCERS: number;
  51914. /** IMAGE PROCESSING */
  51915. IMAGEPROCESSING: boolean;
  51916. VIGNETTE: boolean;
  51917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51918. VIGNETTEBLENDMODEOPAQUE: boolean;
  51919. TONEMAPPING: boolean;
  51920. TONEMAPPING_ACES: boolean;
  51921. CONTRAST: boolean;
  51922. EXPOSURE: boolean;
  51923. COLORCURVES: boolean;
  51924. COLORGRADING: boolean;
  51925. COLORGRADING3D: boolean;
  51926. SAMPLER3DGREENDEPTH: boolean;
  51927. SAMPLER3DBGRMAP: boolean;
  51928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51929. constructor();
  51930. setValue(name: string, value: boolean): void;
  51931. }
  51932. /**
  51933. * Class used to configure NodeMaterial
  51934. */
  51935. export interface INodeMaterialOptions {
  51936. /**
  51937. * Defines if blocks should emit comments
  51938. */
  51939. emitComments: boolean;
  51940. }
  51941. /**
  51942. * Class used to create a node based material built by assembling shader blocks
  51943. */
  51944. export class NodeMaterial extends PushMaterial {
  51945. private static _BuildIdGenerator;
  51946. private _options;
  51947. private _vertexCompilationState;
  51948. private _fragmentCompilationState;
  51949. private _sharedData;
  51950. private _buildId;
  51951. private _buildWasSuccessful;
  51952. private _cachedWorldViewMatrix;
  51953. private _cachedWorldViewProjectionMatrix;
  51954. private _optimizers;
  51955. private _animationFrame;
  51956. /** Define the URl to load node editor script */
  51957. static EditorURL: string;
  51958. private BJSNODEMATERIALEDITOR;
  51959. /** Get the inspector from bundle or global */
  51960. private _getGlobalNodeMaterialEditor;
  51961. /**
  51962. * 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)
  51963. */
  51964. ignoreAlpha: boolean;
  51965. /**
  51966. * Defines the maximum number of lights that can be used in the material
  51967. */
  51968. maxSimultaneousLights: number;
  51969. /**
  51970. * Observable raised when the material is built
  51971. */
  51972. onBuildObservable: Observable<NodeMaterial>;
  51973. /**
  51974. * Gets or sets the root nodes of the material vertex shader
  51975. */
  51976. _vertexOutputNodes: NodeMaterialBlock[];
  51977. /**
  51978. * Gets or sets the root nodes of the material fragment (pixel) shader
  51979. */
  51980. _fragmentOutputNodes: NodeMaterialBlock[];
  51981. /** Gets or sets options to control the node material overall behavior */
  51982. options: INodeMaterialOptions;
  51983. /**
  51984. * Default configuration related to image processing available in the standard Material.
  51985. */
  51986. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51987. /**
  51988. * Gets the image processing configuration used either in this material.
  51989. */
  51990. /**
  51991. * Sets the Default image processing configuration used either in the this material.
  51992. *
  51993. * If sets to null, the scene one is in use.
  51994. */
  51995. imageProcessingConfiguration: ImageProcessingConfiguration;
  51996. /**
  51997. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51998. */
  51999. attachedBlocks: NodeMaterialBlock[];
  52000. /**
  52001. * Create a new node based material
  52002. * @param name defines the material name
  52003. * @param scene defines the hosting scene
  52004. * @param options defines creation option
  52005. */
  52006. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52007. /**
  52008. * Gets the current class name of the material e.g. "NodeMaterial"
  52009. * @returns the class name
  52010. */
  52011. getClassName(): string;
  52012. /**
  52013. * Keep track of the image processing observer to allow dispose and replace.
  52014. */
  52015. private _imageProcessingObserver;
  52016. /**
  52017. * Attaches a new image processing configuration to the Standard Material.
  52018. * @param configuration
  52019. */
  52020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52021. /**
  52022. * Get a block by its name
  52023. * @param name defines the name of the block to retrieve
  52024. * @returns the required block or null if not found
  52025. */
  52026. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52027. /**
  52028. * Gets the list of input blocks attached to this material
  52029. * @returns an array of InputBlocks
  52030. */
  52031. getInputBlocks(): InputBlock[];
  52032. /**
  52033. * Adds a new optimizer to the list of optimizers
  52034. * @param optimizer defines the optimizers to add
  52035. * @returns the current material
  52036. */
  52037. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52038. /**
  52039. * Remove an optimizer from the list of optimizers
  52040. * @param optimizer defines the optimizers to remove
  52041. * @returns the current material
  52042. */
  52043. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52044. /**
  52045. * Add a new block to the list of output nodes
  52046. * @param node defines the node to add
  52047. * @returns the current material
  52048. */
  52049. addOutputNode(node: NodeMaterialBlock): this;
  52050. /**
  52051. * Remove a block from the list of root nodes
  52052. * @param node defines the node to remove
  52053. * @returns the current material
  52054. */
  52055. removeOutputNode(node: NodeMaterialBlock): this;
  52056. private _addVertexOutputNode;
  52057. private _removeVertexOutputNode;
  52058. private _addFragmentOutputNode;
  52059. private _removeFragmentOutputNode;
  52060. /**
  52061. * Specifies if the material will require alpha blending
  52062. * @returns a boolean specifying if alpha blending is needed
  52063. */
  52064. needAlphaBlending(): boolean;
  52065. /**
  52066. * Specifies if this material should be rendered in alpha test mode
  52067. * @returns a boolean specifying if an alpha test is needed.
  52068. */
  52069. needAlphaTesting(): boolean;
  52070. private _initializeBlock;
  52071. private _resetDualBlocks;
  52072. /**
  52073. * Build the material and generates the inner effect
  52074. * @param verbose defines if the build should log activity
  52075. */
  52076. build(verbose?: boolean): void;
  52077. /**
  52078. * Runs an otpimization phase to try to improve the shader code
  52079. */
  52080. optimize(): void;
  52081. private _prepareDefinesForAttributes;
  52082. /**
  52083. * Get if the submesh is ready to be used and all its information available.
  52084. * Child classes can use it to update shaders
  52085. * @param mesh defines the mesh to check
  52086. * @param subMesh defines which submesh to check
  52087. * @param useInstances specifies that instances should be used
  52088. * @returns a boolean indicating that the submesh is ready or not
  52089. */
  52090. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52091. /**
  52092. * Get a string representing the shaders built by the current node graph
  52093. */
  52094. readonly compiledShaders: string;
  52095. /**
  52096. * Binds the world matrix to the material
  52097. * @param world defines the world transformation matrix
  52098. */
  52099. bindOnlyWorldMatrix(world: Matrix): void;
  52100. /**
  52101. * Binds the submesh to this material by preparing the effect and shader to draw
  52102. * @param world defines the world transformation matrix
  52103. * @param mesh defines the mesh containing the submesh
  52104. * @param subMesh defines the submesh to bind the material to
  52105. */
  52106. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52107. /**
  52108. * Gets the active textures from the material
  52109. * @returns an array of textures
  52110. */
  52111. getActiveTextures(): BaseTexture[];
  52112. /**
  52113. * Gets the list of texture blocks
  52114. * @returns an array of texture blocks
  52115. */
  52116. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52117. /**
  52118. * Specifies if the material uses a texture
  52119. * @param texture defines the texture to check against the material
  52120. * @returns a boolean specifying if the material uses the texture
  52121. */
  52122. hasTexture(texture: BaseTexture): boolean;
  52123. /**
  52124. * Disposes the material
  52125. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52126. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52127. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52128. */
  52129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52130. /** Creates the node editor window. */
  52131. private _createNodeEditor;
  52132. /**
  52133. * Launch the node material editor
  52134. * @param config Define the configuration of the editor
  52135. * @return a promise fulfilled when the node editor is visible
  52136. */
  52137. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52138. /**
  52139. * Clear the current material
  52140. */
  52141. clear(): void;
  52142. /**
  52143. * Clear the current material and set it to a default state
  52144. */
  52145. setToDefault(): void;
  52146. /**
  52147. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52148. * @param url defines the url to load from
  52149. * @returns a promise that will fullfil when the material is fully loaded
  52150. */
  52151. loadAsync(url: string): Promise<unknown>;
  52152. private _gatherBlocks;
  52153. /**
  52154. * Generate a string containing the code declaration required to create an equivalent of this material
  52155. * @returns a string
  52156. */
  52157. generateCode(): string;
  52158. /**
  52159. * Serializes this material in a JSON representation
  52160. * @returns the serialized material object
  52161. */
  52162. serialize(): any;
  52163. private _restoreConnections;
  52164. /**
  52165. * Clear the current graph and load a new one from a serialization object
  52166. * @param source defines the JSON representation of the material
  52167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52168. */
  52169. loadFromSerialization(source: any, rootUrl?: string): void;
  52170. /**
  52171. * Creates a node material from parsed material data
  52172. * @param source defines the JSON representation of the material
  52173. * @param scene defines the hosting scene
  52174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52175. * @returns a new node material
  52176. */
  52177. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52178. /**
  52179. * Creates a new node material set to default basic configuration
  52180. * @param name defines the name of the material
  52181. * @param scene defines the hosting scene
  52182. * @returns a new NodeMaterial
  52183. */
  52184. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52185. }
  52186. }
  52187. declare module BABYLON {
  52188. /**
  52189. * Block used to read a texture from a sampler
  52190. */
  52191. export class TextureBlock extends NodeMaterialBlock {
  52192. private _defineName;
  52193. private _samplerName;
  52194. private _transformedUVName;
  52195. private _textureTransformName;
  52196. private _textureInfoName;
  52197. private _mainUVName;
  52198. private _mainUVDefineName;
  52199. /**
  52200. * Gets or sets the texture associated with the node
  52201. */
  52202. texture: Nullable<BaseTexture>;
  52203. /**
  52204. * Create a new TextureBlock
  52205. * @param name defines the block name
  52206. */
  52207. constructor(name: string);
  52208. /**
  52209. * Gets the current class name
  52210. * @returns the class name
  52211. */
  52212. getClassName(): string;
  52213. /**
  52214. * Gets the uv input component
  52215. */
  52216. readonly uv: NodeMaterialConnectionPoint;
  52217. /**
  52218. * Gets the rgba output component
  52219. */
  52220. readonly rgba: NodeMaterialConnectionPoint;
  52221. /**
  52222. * Gets the rgb output component
  52223. */
  52224. readonly rgb: NodeMaterialConnectionPoint;
  52225. /**
  52226. * Gets the r output component
  52227. */
  52228. readonly r: NodeMaterialConnectionPoint;
  52229. /**
  52230. * Gets the g output component
  52231. */
  52232. readonly g: NodeMaterialConnectionPoint;
  52233. /**
  52234. * Gets the b output component
  52235. */
  52236. readonly b: NodeMaterialConnectionPoint;
  52237. /**
  52238. * Gets the a output component
  52239. */
  52240. readonly a: NodeMaterialConnectionPoint;
  52241. readonly target: NodeMaterialBlockTargets;
  52242. autoConfigure(): void;
  52243. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52245. isReady(): boolean;
  52246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52247. private readonly _isMixed;
  52248. private _injectVertexCode;
  52249. private _writeOutput;
  52250. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52251. protected _dumpPropertiesCode(): string;
  52252. serialize(): any;
  52253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52254. }
  52255. }
  52256. declare module BABYLON {
  52257. /**
  52258. * Class used to store shared data between 2 NodeMaterialBuildState
  52259. */
  52260. export class NodeMaterialBuildStateSharedData {
  52261. /**
  52262. * Gets the list of emitted varyings
  52263. */
  52264. temps: string[];
  52265. /**
  52266. * Gets the list of emitted varyings
  52267. */
  52268. varyings: string[];
  52269. /**
  52270. * Gets the varying declaration string
  52271. */
  52272. varyingDeclaration: string;
  52273. /**
  52274. * Input blocks
  52275. */
  52276. inputBlocks: InputBlock[];
  52277. /**
  52278. * Input blocks
  52279. */
  52280. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52281. /**
  52282. * Bindable blocks (Blocks that need to set data to the effect)
  52283. */
  52284. bindableBlocks: NodeMaterialBlock[];
  52285. /**
  52286. * List of blocks that can provide a compilation fallback
  52287. */
  52288. blocksWithFallbacks: NodeMaterialBlock[];
  52289. /**
  52290. * List of blocks that can provide a define update
  52291. */
  52292. blocksWithDefines: NodeMaterialBlock[];
  52293. /**
  52294. * List of blocks that can provide a repeatable content
  52295. */
  52296. repeatableContentBlocks: NodeMaterialBlock[];
  52297. /**
  52298. * List of blocks that can provide a dynamic list of uniforms
  52299. */
  52300. dynamicUniformBlocks: NodeMaterialBlock[];
  52301. /**
  52302. * List of blocks that can block the isReady function for the material
  52303. */
  52304. blockingBlocks: NodeMaterialBlock[];
  52305. /**
  52306. * Gets the list of animated inputs
  52307. */
  52308. animatedInputs: InputBlock[];
  52309. /**
  52310. * Build Id used to avoid multiple recompilations
  52311. */
  52312. buildId: number;
  52313. /** List of emitted variables */
  52314. variableNames: {
  52315. [key: string]: number;
  52316. };
  52317. /** List of emitted defines */
  52318. defineNames: {
  52319. [key: string]: number;
  52320. };
  52321. /** Should emit comments? */
  52322. emitComments: boolean;
  52323. /** Emit build activity */
  52324. verbose: boolean;
  52325. /**
  52326. * Gets the compilation hints emitted at compilation time
  52327. */
  52328. hints: {
  52329. needWorldViewMatrix: boolean;
  52330. needWorldViewProjectionMatrix: boolean;
  52331. needAlphaBlending: boolean;
  52332. needAlphaTesting: boolean;
  52333. };
  52334. /**
  52335. * List of compilation checks
  52336. */
  52337. checks: {
  52338. emitVertex: boolean;
  52339. emitFragment: boolean;
  52340. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52341. };
  52342. /** Creates a new shared data */
  52343. constructor();
  52344. /**
  52345. * Emits console errors and exceptions if there is a failing check
  52346. */
  52347. emitErrors(): void;
  52348. }
  52349. }
  52350. declare module BABYLON {
  52351. /**
  52352. * Class used to store node based material build state
  52353. */
  52354. export class NodeMaterialBuildState {
  52355. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52356. supportUniformBuffers: boolean;
  52357. /**
  52358. * Gets the list of emitted attributes
  52359. */
  52360. attributes: string[];
  52361. /**
  52362. * Gets the list of emitted uniforms
  52363. */
  52364. uniforms: string[];
  52365. /**
  52366. * Gets the list of emitted uniform buffers
  52367. */
  52368. uniformBuffers: string[];
  52369. /**
  52370. * Gets the list of emitted samplers
  52371. */
  52372. samplers: string[];
  52373. /**
  52374. * Gets the list of emitted functions
  52375. */
  52376. functions: {
  52377. [key: string]: string;
  52378. };
  52379. /**
  52380. * Gets the target of the compilation state
  52381. */
  52382. target: NodeMaterialBlockTargets;
  52383. /**
  52384. * Gets the list of emitted counters
  52385. */
  52386. counters: {
  52387. [key: string]: number;
  52388. };
  52389. /**
  52390. * Shared data between multiple NodeMaterialBuildState instances
  52391. */
  52392. sharedData: NodeMaterialBuildStateSharedData;
  52393. /** @hidden */
  52394. _vertexState: NodeMaterialBuildState;
  52395. /** @hidden */
  52396. _attributeDeclaration: string;
  52397. /** @hidden */
  52398. _uniformDeclaration: string;
  52399. /** @hidden */
  52400. _samplerDeclaration: string;
  52401. /** @hidden */
  52402. _varyingTransfer: string;
  52403. private _repeatableContentAnchorIndex;
  52404. /** @hidden */
  52405. _builtCompilationString: string;
  52406. /**
  52407. * Gets the emitted compilation strings
  52408. */
  52409. compilationString: string;
  52410. /**
  52411. * Finalize the compilation strings
  52412. * @param state defines the current compilation state
  52413. */
  52414. finalize(state: NodeMaterialBuildState): void;
  52415. /** @hidden */
  52416. readonly _repeatableContentAnchor: string;
  52417. /** @hidden */
  52418. _getFreeVariableName(prefix: string): string;
  52419. /** @hidden */
  52420. _getFreeDefineName(prefix: string): string;
  52421. /** @hidden */
  52422. _excludeVariableName(name: string): void;
  52423. /** @hidden */
  52424. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52425. /** @hidden */
  52426. _emitFunction(name: string, code: string, comments: string): void;
  52427. /** @hidden */
  52428. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52429. replaceStrings?: {
  52430. search: RegExp;
  52431. replace: string;
  52432. }[];
  52433. repeatKey?: string;
  52434. }): string;
  52435. /** @hidden */
  52436. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52437. repeatKey?: string;
  52438. removeAttributes?: boolean;
  52439. removeUniforms?: boolean;
  52440. removeVaryings?: boolean;
  52441. removeIfDef?: boolean;
  52442. replaceStrings?: {
  52443. search: RegExp;
  52444. replace: string;
  52445. }[];
  52446. }, storeKey?: string): void;
  52447. /** @hidden */
  52448. _registerTempVariable(name: string): boolean;
  52449. /** @hidden */
  52450. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52451. /** @hidden */
  52452. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /**
  52457. * Defines a block that can be used inside a node based material
  52458. */
  52459. export class NodeMaterialBlock {
  52460. private _buildId;
  52461. private _buildTarget;
  52462. private _target;
  52463. private _isFinalMerger;
  52464. private _isInput;
  52465. /** @hidden */
  52466. _codeVariableName: string;
  52467. /** @hidden */
  52468. _inputs: NodeMaterialConnectionPoint[];
  52469. /** @hidden */
  52470. _outputs: NodeMaterialConnectionPoint[];
  52471. /**
  52472. * Gets or sets the name of the block
  52473. */
  52474. name: string;
  52475. /**
  52476. * Gets or sets the unique id of the node
  52477. */
  52478. uniqueId: number;
  52479. /**
  52480. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52481. */
  52482. readonly isFinalMerger: boolean;
  52483. /**
  52484. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52485. */
  52486. readonly isInput: boolean;
  52487. /**
  52488. * Gets or sets the build Id
  52489. */
  52490. buildId: number;
  52491. /**
  52492. * Gets or sets the target of the block
  52493. */
  52494. target: NodeMaterialBlockTargets;
  52495. /**
  52496. * Gets the list of input points
  52497. */
  52498. readonly inputs: NodeMaterialConnectionPoint[];
  52499. /** Gets the list of output points */
  52500. readonly outputs: NodeMaterialConnectionPoint[];
  52501. /**
  52502. * Find an input by its name
  52503. * @param name defines the name of the input to look for
  52504. * @returns the input or null if not found
  52505. */
  52506. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52507. /**
  52508. * Find an output by its name
  52509. * @param name defines the name of the outputto look for
  52510. * @returns the output or null if not found
  52511. */
  52512. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52513. /**
  52514. * Creates a new NodeMaterialBlock
  52515. * @param name defines the block name
  52516. * @param target defines the target of that block (Vertex by default)
  52517. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52518. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52519. */
  52520. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52521. /**
  52522. * Initialize the block and prepare the context for build
  52523. * @param state defines the state that will be used for the build
  52524. */
  52525. initialize(state: NodeMaterialBuildState): void;
  52526. /**
  52527. * Bind data to effect. Will only be called for blocks with isBindable === true
  52528. * @param effect defines the effect to bind data to
  52529. * @param nodeMaterial defines the hosting NodeMaterial
  52530. * @param mesh defines the mesh that will be rendered
  52531. */
  52532. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52533. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52534. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52535. protected _writeFloat(value: number): string;
  52536. /**
  52537. * Gets the current class name e.g. "NodeMaterialBlock"
  52538. * @returns the class name
  52539. */
  52540. getClassName(): string;
  52541. /**
  52542. * Register a new input. Must be called inside a block constructor
  52543. * @param name defines the connection point name
  52544. * @param type defines the connection point type
  52545. * @param isOptional defines a boolean indicating that this input can be omitted
  52546. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52547. * @returns the current block
  52548. */
  52549. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52550. /**
  52551. * Register a new output. Must be called inside a block constructor
  52552. * @param name defines the connection point name
  52553. * @param type defines the connection point type
  52554. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52555. * @returns the current block
  52556. */
  52557. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52558. /**
  52559. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52560. * @param forOutput defines an optional connection point to check compatibility with
  52561. * @returns the first available input or null
  52562. */
  52563. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52564. /**
  52565. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52566. * @param forBlock defines an optional block to check compatibility with
  52567. * @returns the first available input or null
  52568. */
  52569. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52570. /**
  52571. * Gets the sibling of the given output
  52572. * @param current defines the current output
  52573. * @returns the next output in the list or null
  52574. */
  52575. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52576. /**
  52577. * Connect current block with another block
  52578. * @param other defines the block to connect with
  52579. * @param options define the various options to help pick the right connections
  52580. * @returns the current block
  52581. */
  52582. connectTo(other: NodeMaterialBlock, options?: {
  52583. input?: string;
  52584. output?: string;
  52585. outputSwizzle?: string;
  52586. }): this | undefined;
  52587. protected _buildBlock(state: NodeMaterialBuildState): void;
  52588. /**
  52589. * Add uniforms, samplers and uniform buffers at compilation time
  52590. * @param state defines the state to update
  52591. * @param nodeMaterial defines the node material requesting the update
  52592. * @param defines defines the material defines to update
  52593. */
  52594. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52595. /**
  52596. * Add potential fallbacks if shader compilation fails
  52597. * @param mesh defines the mesh to be rendered
  52598. * @param fallbacks defines the current prioritized list of fallbacks
  52599. */
  52600. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52601. /**
  52602. * Update defines for shader compilation
  52603. * @param mesh defines the mesh to be rendered
  52604. * @param nodeMaterial defines the node material requesting the update
  52605. * @param defines defines the material defines to update
  52606. * @param useInstances specifies that instances should be used
  52607. */
  52608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52609. /**
  52610. * Initialize defines for shader compilation
  52611. * @param mesh defines the mesh to be rendered
  52612. * @param nodeMaterial defines the node material requesting the update
  52613. * @param defines defines the material defines to be prepared
  52614. * @param useInstances specifies that instances should be used
  52615. */
  52616. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52617. /**
  52618. * Lets the block try to connect some inputs automatically
  52619. * @param material defines the hosting NodeMaterial
  52620. */
  52621. autoConfigure(material: NodeMaterial): void;
  52622. /**
  52623. * Function called when a block is declared as repeatable content generator
  52624. * @param vertexShaderState defines the current compilation state for the vertex shader
  52625. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52626. * @param mesh defines the mesh to be rendered
  52627. * @param defines defines the material defines to update
  52628. */
  52629. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52630. /**
  52631. * Checks if the block is ready
  52632. * @param mesh defines the mesh to be rendered
  52633. * @param nodeMaterial defines the node material requesting the update
  52634. * @param defines defines the material defines to update
  52635. * @param useInstances specifies that instances should be used
  52636. * @returns true if the block is ready
  52637. */
  52638. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52639. private _processBuild;
  52640. /**
  52641. * Compile the current node and generate the shader code
  52642. * @param state defines the current compilation state (uniforms, samplers, current string)
  52643. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52644. * @returns true if already built
  52645. */
  52646. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52647. protected _inputRename(name: string): string;
  52648. protected _outputRename(name: string): string;
  52649. protected _dumpPropertiesCode(): string;
  52650. /** @hidden */
  52651. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52652. /**
  52653. * Clone the current block to a new identical block
  52654. * @param scene defines the hosting scene
  52655. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52656. * @returns a copy of the current block
  52657. */
  52658. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52659. /**
  52660. * Serializes this block in a JSON representation
  52661. * @returns the serialized block object
  52662. */
  52663. serialize(): any;
  52664. /** @hidden */
  52665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52666. }
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52671. */
  52672. export enum NodeMaterialBlockConnectionPointMode {
  52673. /** Value is an uniform */
  52674. Uniform = 0,
  52675. /** Value is a mesh attribute */
  52676. Attribute = 1,
  52677. /** Value is a varying between vertex and fragment shaders */
  52678. Varying = 2,
  52679. /** Mode is undefined */
  52680. Undefined = 3
  52681. }
  52682. }
  52683. declare module BABYLON {
  52684. /**
  52685. * Enum defining the type of animations supported by InputBlock
  52686. */
  52687. export enum AnimatedInputBlockTypes {
  52688. /** No animation */
  52689. None = 0,
  52690. /** Time based animation. Will only work for floats */
  52691. Time = 1
  52692. }
  52693. }
  52694. declare module BABYLON {
  52695. /**
  52696. * Block used to expose an input value
  52697. */
  52698. export class InputBlock extends NodeMaterialBlock {
  52699. private _mode;
  52700. private _associatedVariableName;
  52701. private _storedValue;
  52702. private _valueCallback;
  52703. private _type;
  52704. private _animationType;
  52705. /** @hidden */
  52706. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52707. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52708. visibleInInspector: boolean;
  52709. /**
  52710. * Gets or sets the connection point type (default is float)
  52711. */
  52712. readonly type: NodeMaterialBlockConnectionPointTypes;
  52713. /**
  52714. * Creates a new InputBlock
  52715. * @param name defines the block name
  52716. * @param target defines the target of that block (Vertex by default)
  52717. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52718. */
  52719. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52720. /**
  52721. * Gets the output component
  52722. */
  52723. readonly output: NodeMaterialConnectionPoint;
  52724. /**
  52725. * Set the source of this connection point to a vertex attribute
  52726. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52727. * @returns the current connection point
  52728. */
  52729. setAsAttribute(attributeName?: string): InputBlock;
  52730. /**
  52731. * Set the source of this connection point to a well known value
  52732. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  52733. * @returns the current connection point
  52734. */
  52735. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  52736. /**
  52737. * Gets or sets the value of that point.
  52738. * Please note that this value will be ignored if valueCallback is defined
  52739. */
  52740. value: any;
  52741. /**
  52742. * Gets or sets a callback used to get the value of that point.
  52743. * Please note that setting this value will force the connection point to ignore the value property
  52744. */
  52745. valueCallback: () => any;
  52746. /**
  52747. * Gets or sets the associated variable name in the shader
  52748. */
  52749. associatedVariableName: string;
  52750. /** Gets or sets the type of animation applied to the input */
  52751. animationType: AnimatedInputBlockTypes;
  52752. /**
  52753. * Gets a boolean indicating that this connection point not defined yet
  52754. */
  52755. readonly isUndefined: boolean;
  52756. /**
  52757. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52758. * In this case the connection point name must be the name of the uniform to use.
  52759. * Can only be set on inputs
  52760. */
  52761. isUniform: boolean;
  52762. /**
  52763. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52764. * In this case the connection point name must be the name of the attribute to use
  52765. * Can only be set on inputs
  52766. */
  52767. isAttribute: boolean;
  52768. /**
  52769. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52770. * Can only be set on exit points
  52771. */
  52772. isVarying: boolean;
  52773. /**
  52774. * Gets a boolean indicating that the current connection point is a well known value
  52775. */
  52776. readonly isWellKnownValue: boolean;
  52777. /**
  52778. * Gets or sets the current well known value or null if not defined as well know value
  52779. */
  52780. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52781. /**
  52782. * Gets the current class name
  52783. * @returns the class name
  52784. */
  52785. getClassName(): string;
  52786. /**
  52787. * Animate the input if animationType !== None
  52788. * @param scene defines the rendering scene
  52789. */
  52790. animate(scene: Scene): void;
  52791. private _emitDefine;
  52792. /**
  52793. * Set the input block to its default value (based on its type)
  52794. */
  52795. setDefaultValue(): void;
  52796. protected _dumpPropertiesCode(): string;
  52797. private _emit;
  52798. /** @hidden */
  52799. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52800. /** @hidden */
  52801. _transmit(effect: Effect, scene: Scene): void;
  52802. protected _buildBlock(state: NodeMaterialBuildState): void;
  52803. serialize(): any;
  52804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52805. }
  52806. }
  52807. declare module BABYLON {
  52808. /**
  52809. * Defines a connection point for a block
  52810. */
  52811. export class NodeMaterialConnectionPoint {
  52812. /** @hidden */
  52813. _ownerBlock: NodeMaterialBlock;
  52814. /** @hidden */
  52815. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52816. private _endpoints;
  52817. private _associatedVariableName;
  52818. /** @hidden */
  52819. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52820. private _type;
  52821. /** @hidden */
  52822. _enforceAssociatedVariableName: boolean;
  52823. /**
  52824. * Gets or sets the additional types supported byt this connection point
  52825. */
  52826. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52827. /**
  52828. * Gets or sets the associated variable name in the shader
  52829. */
  52830. associatedVariableName: string;
  52831. /**
  52832. * Gets or sets the connection point type (default is float)
  52833. */
  52834. type: NodeMaterialBlockConnectionPointTypes;
  52835. /**
  52836. * Gets or sets the connection point name
  52837. */
  52838. name: string;
  52839. /**
  52840. * Gets or sets a boolean indicating that this connection point can be omitted
  52841. */
  52842. isOptional: boolean;
  52843. /**
  52844. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52845. */
  52846. define: string;
  52847. /** Gets or sets the target of that connection point */
  52848. target: NodeMaterialBlockTargets;
  52849. /**
  52850. * Gets a boolean indicating that the current point is connected
  52851. */
  52852. readonly isConnected: boolean;
  52853. /**
  52854. * Gets a boolean indicating that the current point is connected to an input block
  52855. */
  52856. readonly isConnectedToInputBlock: boolean;
  52857. /**
  52858. * Gets a the connected input block (if any)
  52859. */
  52860. readonly connectInputBlock: Nullable<InputBlock>;
  52861. /** Get the other side of the connection (if any) */
  52862. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52863. /** Get the block that owns this connection point */
  52864. readonly ownerBlock: NodeMaterialBlock;
  52865. /** Get the block connected on the other side of this connection (if any) */
  52866. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52867. /** Get the block connected on the endpoints of this connection (if any) */
  52868. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52869. /** Gets the list of connected endpoints */
  52870. readonly endpoints: NodeMaterialConnectionPoint[];
  52871. /** Gets a boolean indicating if that output point is connected to at least one input */
  52872. readonly hasEndpoints: boolean;
  52873. /**
  52874. * Creates a new connection point
  52875. * @param name defines the connection point name
  52876. * @param ownerBlock defines the block hosting this connection point
  52877. */
  52878. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52879. /**
  52880. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52881. * @returns the class name
  52882. */
  52883. getClassName(): string;
  52884. /**
  52885. * Gets an boolean indicating if the current point can be connected to another point
  52886. * @param connectionPoint defines the other connection point
  52887. * @returns true if the connection is possible
  52888. */
  52889. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52890. /**
  52891. * Connect this point to another connection point
  52892. * @param connectionPoint defines the other connection point
  52893. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  52894. * @returns the current connection point
  52895. */
  52896. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  52897. /**
  52898. * Disconnect this point from one of his endpoint
  52899. * @param endpoint defines the other connection point
  52900. * @returns the current connection point
  52901. */
  52902. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  52903. /**
  52904. * Serializes this point in a JSON representation
  52905. * @returns the serialized point object
  52906. */
  52907. serialize(): any;
  52908. }
  52909. }
  52910. declare module BABYLON {
  52911. /**
  52912. * Block used to add support for vertex skinning (bones)
  52913. */
  52914. export class BonesBlock extends NodeMaterialBlock {
  52915. /**
  52916. * Creates a new BonesBlock
  52917. * @param name defines the block name
  52918. */
  52919. constructor(name: string);
  52920. /**
  52921. * Initialize the block and prepare the context for build
  52922. * @param state defines the state that will be used for the build
  52923. */
  52924. initialize(state: NodeMaterialBuildState): void;
  52925. /**
  52926. * Gets the current class name
  52927. * @returns the class name
  52928. */
  52929. getClassName(): string;
  52930. /**
  52931. * Gets the matrix indices input component
  52932. */
  52933. readonly matricesIndices: NodeMaterialConnectionPoint;
  52934. /**
  52935. * Gets the matrix weights input component
  52936. */
  52937. readonly matricesWeights: NodeMaterialConnectionPoint;
  52938. /**
  52939. * Gets the extra matrix indices input component
  52940. */
  52941. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52942. /**
  52943. * Gets the extra matrix weights input component
  52944. */
  52945. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52946. /**
  52947. * Gets the world input component
  52948. */
  52949. readonly world: NodeMaterialConnectionPoint;
  52950. /**
  52951. * Gets the output component
  52952. */
  52953. readonly output: NodeMaterialConnectionPoint;
  52954. autoConfigure(): void;
  52955. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52958. protected _buildBlock(state: NodeMaterialBuildState): this;
  52959. }
  52960. }
  52961. declare module BABYLON {
  52962. /**
  52963. * Block used to add support for instances
  52964. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52965. */
  52966. export class InstancesBlock extends NodeMaterialBlock {
  52967. /**
  52968. * Creates a new InstancesBlock
  52969. * @param name defines the block name
  52970. */
  52971. constructor(name: string);
  52972. /**
  52973. * Gets the current class name
  52974. * @returns the class name
  52975. */
  52976. getClassName(): string;
  52977. /**
  52978. * Gets the first world row input component
  52979. */
  52980. readonly world0: NodeMaterialConnectionPoint;
  52981. /**
  52982. * Gets the second world row input component
  52983. */
  52984. readonly world1: NodeMaterialConnectionPoint;
  52985. /**
  52986. * Gets the third world row input component
  52987. */
  52988. readonly world2: NodeMaterialConnectionPoint;
  52989. /**
  52990. * Gets the forth world row input component
  52991. */
  52992. readonly world3: NodeMaterialConnectionPoint;
  52993. /**
  52994. * Gets the world input component
  52995. */
  52996. readonly world: NodeMaterialConnectionPoint;
  52997. /**
  52998. * Gets the output component
  52999. */
  53000. readonly output: NodeMaterialConnectionPoint;
  53001. autoConfigure(): void;
  53002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53003. protected _buildBlock(state: NodeMaterialBuildState): this;
  53004. }
  53005. }
  53006. declare module BABYLON {
  53007. /**
  53008. * Block used to add morph targets support to vertex shader
  53009. */
  53010. export class MorphTargetsBlock extends NodeMaterialBlock {
  53011. private _repeatableContentAnchor;
  53012. private _repeatebleContentGenerated;
  53013. /**
  53014. * Create a new MorphTargetsBlock
  53015. * @param name defines the block name
  53016. */
  53017. constructor(name: string);
  53018. /**
  53019. * Gets the current class name
  53020. * @returns the class name
  53021. */
  53022. getClassName(): string;
  53023. /**
  53024. * Gets the position input component
  53025. */
  53026. readonly position: NodeMaterialConnectionPoint;
  53027. /**
  53028. * Gets the normal input component
  53029. */
  53030. readonly normal: NodeMaterialConnectionPoint;
  53031. /**
  53032. * Gets the tangent input component
  53033. */
  53034. readonly tangent: NodeMaterialConnectionPoint;
  53035. /**
  53036. * Gets the tangent input component
  53037. */
  53038. readonly uv: NodeMaterialConnectionPoint;
  53039. /**
  53040. * Gets the position output component
  53041. */
  53042. readonly positionOutput: NodeMaterialConnectionPoint;
  53043. /**
  53044. * Gets the normal output component
  53045. */
  53046. readonly normalOutput: NodeMaterialConnectionPoint;
  53047. /**
  53048. * Gets the tangent output component
  53049. */
  53050. readonly tangentOutput: NodeMaterialConnectionPoint;
  53051. /**
  53052. * Gets the tangent output component
  53053. */
  53054. readonly uvOutput: NodeMaterialConnectionPoint;
  53055. initialize(state: NodeMaterialBuildState): void;
  53056. autoConfigure(): void;
  53057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53059. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53060. protected _buildBlock(state: NodeMaterialBuildState): this;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * Block used to add an alpha test in the fragment shader
  53066. */
  53067. export class AlphaTestBlock extends NodeMaterialBlock {
  53068. /**
  53069. * Gets or sets the alpha value where alpha testing happens
  53070. */
  53071. alphaCutOff: number;
  53072. /**
  53073. * Create a new AlphaTestBlock
  53074. * @param name defines the block name
  53075. */
  53076. constructor(name: string);
  53077. /**
  53078. * Gets the current class name
  53079. * @returns the class name
  53080. */
  53081. getClassName(): string;
  53082. /**
  53083. * Gets the color input component
  53084. */
  53085. readonly color: NodeMaterialConnectionPoint;
  53086. /**
  53087. * Gets the alpha input component
  53088. */
  53089. readonly alpha: NodeMaterialConnectionPoint;
  53090. protected _buildBlock(state: NodeMaterialBuildState): this;
  53091. protected _dumpPropertiesCode(): string;
  53092. serialize(): any;
  53093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53094. }
  53095. }
  53096. declare module BABYLON {
  53097. /**
  53098. * Block used to compute fresnel value
  53099. */
  53100. export class FresnelBlock extends NodeMaterialBlock {
  53101. /**
  53102. * Create a new FresnelBlock
  53103. * @param name defines the block name
  53104. */
  53105. constructor(name: string);
  53106. /**
  53107. * Gets the current class name
  53108. * @returns the class name
  53109. */
  53110. getClassName(): string;
  53111. /**
  53112. * Gets the world position input component
  53113. */
  53114. readonly worldPosition: NodeMaterialConnectionPoint;
  53115. /**
  53116. * Gets the world normal input component
  53117. */
  53118. readonly worldNormal: NodeMaterialConnectionPoint;
  53119. /**
  53120. * Gets the camera (or eye) position component
  53121. */
  53122. readonly cameraPosition: NodeMaterialConnectionPoint;
  53123. /**
  53124. * Gets the bias input component
  53125. */
  53126. readonly bias: NodeMaterialConnectionPoint;
  53127. /**
  53128. * Gets the camera (or eye) position component
  53129. */
  53130. readonly power: NodeMaterialConnectionPoint;
  53131. /**
  53132. * Gets the fresnel output component
  53133. */
  53134. readonly fresnel: NodeMaterialConnectionPoint;
  53135. autoConfigure(material: NodeMaterial): void;
  53136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * Block used to add image processing support to fragment shader
  53142. */
  53143. export class ImageProcessingBlock extends NodeMaterialBlock {
  53144. /**
  53145. * Create a new ImageProcessingBlock
  53146. * @param name defines the block name
  53147. */
  53148. constructor(name: string);
  53149. /**
  53150. * Gets the current class name
  53151. * @returns the class name
  53152. */
  53153. getClassName(): string;
  53154. /**
  53155. * Gets the color input component
  53156. */
  53157. readonly color: NodeMaterialConnectionPoint;
  53158. /**
  53159. * Gets the output component
  53160. */
  53161. readonly output: NodeMaterialConnectionPoint;
  53162. /**
  53163. * Initialize the block and prepare the context for build
  53164. * @param state defines the state that will be used for the build
  53165. */
  53166. initialize(state: NodeMaterialBuildState): void;
  53167. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53170. protected _buildBlock(state: NodeMaterialBuildState): this;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Block used to add support for scene fog
  53176. */
  53177. export class FogBlock extends NodeMaterialBlock {
  53178. private _fogDistanceName;
  53179. private _fogParameters;
  53180. /**
  53181. * Create a new FogBlock
  53182. * @param name defines the block name
  53183. */
  53184. constructor(name: string);
  53185. /**
  53186. * Gets the current class name
  53187. * @returns the class name
  53188. */
  53189. getClassName(): string;
  53190. /**
  53191. * Gets the world position input component
  53192. */
  53193. readonly worldPosition: NodeMaterialConnectionPoint;
  53194. /**
  53195. * Gets the view input component
  53196. */
  53197. readonly view: NodeMaterialConnectionPoint;
  53198. /**
  53199. * Gets the color input component
  53200. */
  53201. readonly input: NodeMaterialConnectionPoint;
  53202. /**
  53203. * Gets the fog color input component
  53204. */
  53205. readonly fogColor: NodeMaterialConnectionPoint;
  53206. /**
  53207. * Gets the output component
  53208. */
  53209. readonly output: NodeMaterialConnectionPoint;
  53210. autoConfigure(): void;
  53211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53213. protected _buildBlock(state: NodeMaterialBuildState): this;
  53214. }
  53215. }
  53216. declare module BABYLON {
  53217. /**
  53218. * Block used to add light in the fragment shader
  53219. */
  53220. export class LightBlock extends NodeMaterialBlock {
  53221. private _lightId;
  53222. /**
  53223. * Gets or sets the light associated with this block
  53224. */
  53225. light: Nullable<Light>;
  53226. /**
  53227. * Create a new LightBlock
  53228. * @param name defines the block name
  53229. */
  53230. constructor(name: string);
  53231. /**
  53232. * Gets the current class name
  53233. * @returns the class name
  53234. */
  53235. getClassName(): string;
  53236. /**
  53237. * Gets the world position input component
  53238. */
  53239. readonly worldPosition: NodeMaterialConnectionPoint;
  53240. /**
  53241. * Gets the world normal input component
  53242. */
  53243. readonly worldNormal: NodeMaterialConnectionPoint;
  53244. /**
  53245. * Gets the camera (or eye) position component
  53246. */
  53247. readonly cameraPosition: NodeMaterialConnectionPoint;
  53248. /**
  53249. * Gets the diffuse output component
  53250. */
  53251. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53252. /**
  53253. * Gets the specular output component
  53254. */
  53255. readonly specularOutput: NodeMaterialConnectionPoint;
  53256. autoConfigure(): void;
  53257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53258. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53260. private _injectVertexCode;
  53261. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53262. serialize(): any;
  53263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53264. }
  53265. }
  53266. declare module BABYLON {
  53267. /**
  53268. * Block used to multiply 2 values
  53269. */
  53270. export class MultiplyBlock extends NodeMaterialBlock {
  53271. /**
  53272. * Creates a new MultiplyBlock
  53273. * @param name defines the block name
  53274. */
  53275. constructor(name: string);
  53276. /**
  53277. * Gets the current class name
  53278. * @returns the class name
  53279. */
  53280. getClassName(): string;
  53281. /**
  53282. * Gets the left operand input component
  53283. */
  53284. readonly left: NodeMaterialConnectionPoint;
  53285. /**
  53286. * Gets the right operand input component
  53287. */
  53288. readonly right: NodeMaterialConnectionPoint;
  53289. /**
  53290. * Gets the output component
  53291. */
  53292. readonly output: NodeMaterialConnectionPoint;
  53293. protected _buildBlock(state: NodeMaterialBuildState): this;
  53294. }
  53295. }
  53296. declare module BABYLON {
  53297. /**
  53298. * Block used to add 2 vectors
  53299. */
  53300. export class AddBlock extends NodeMaterialBlock {
  53301. /**
  53302. * Creates a new AddBlock
  53303. * @param name defines the block name
  53304. */
  53305. constructor(name: string);
  53306. /**
  53307. * Gets the current class name
  53308. * @returns the class name
  53309. */
  53310. getClassName(): string;
  53311. /**
  53312. * Gets the left operand input component
  53313. */
  53314. readonly left: NodeMaterialConnectionPoint;
  53315. /**
  53316. * Gets the right operand input component
  53317. */
  53318. readonly right: NodeMaterialConnectionPoint;
  53319. /**
  53320. * Gets the output component
  53321. */
  53322. readonly output: NodeMaterialConnectionPoint;
  53323. protected _buildBlock(state: NodeMaterialBuildState): this;
  53324. }
  53325. }
  53326. declare module BABYLON {
  53327. /**
  53328. * Block used to scale a vector by a float
  53329. */
  53330. export class ScaleBlock extends NodeMaterialBlock {
  53331. /**
  53332. * Creates a new ScaleBlock
  53333. * @param name defines the block name
  53334. */
  53335. constructor(name: string);
  53336. /**
  53337. * Gets the current class name
  53338. * @returns the class name
  53339. */
  53340. getClassName(): string;
  53341. /**
  53342. * Gets the input component
  53343. */
  53344. readonly input: NodeMaterialConnectionPoint;
  53345. /**
  53346. * Gets the factor input component
  53347. */
  53348. readonly factor: NodeMaterialConnectionPoint;
  53349. /**
  53350. * Gets the output component
  53351. */
  53352. readonly output: NodeMaterialConnectionPoint;
  53353. protected _buildBlock(state: NodeMaterialBuildState): this;
  53354. }
  53355. }
  53356. declare module BABYLON {
  53357. /**
  53358. * Block used to clamp a float
  53359. */
  53360. export class ClampBlock extends NodeMaterialBlock {
  53361. /** Gets or sets the minimum range */
  53362. minimum: number;
  53363. /** Gets or sets the maximum range */
  53364. maximum: number;
  53365. /**
  53366. * Creates a new ClampBlock
  53367. * @param name defines the block name
  53368. */
  53369. constructor(name: string);
  53370. /**
  53371. * Gets the current class name
  53372. * @returns the class name
  53373. */
  53374. getClassName(): string;
  53375. /**
  53376. * Gets the value input component
  53377. */
  53378. readonly value: NodeMaterialConnectionPoint;
  53379. /**
  53380. * Gets the output component
  53381. */
  53382. readonly output: NodeMaterialConnectionPoint;
  53383. protected _buildBlock(state: NodeMaterialBuildState): this;
  53384. protected _dumpPropertiesCode(): string;
  53385. serialize(): any;
  53386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53387. }
  53388. }
  53389. declare module BABYLON {
  53390. /**
  53391. * Block used to apply a cross product between 2 vectors
  53392. */
  53393. export class CrossBlock extends NodeMaterialBlock {
  53394. /**
  53395. * Creates a new CrossBlock
  53396. * @param name defines the block name
  53397. */
  53398. constructor(name: string);
  53399. /**
  53400. * Gets the current class name
  53401. * @returns the class name
  53402. */
  53403. getClassName(): string;
  53404. /**
  53405. * Gets the left operand input component
  53406. */
  53407. readonly left: NodeMaterialConnectionPoint;
  53408. /**
  53409. * Gets the right operand input component
  53410. */
  53411. readonly right: NodeMaterialConnectionPoint;
  53412. /**
  53413. * Gets the output component
  53414. */
  53415. readonly output: NodeMaterialConnectionPoint;
  53416. protected _buildBlock(state: NodeMaterialBuildState): this;
  53417. }
  53418. }
  53419. declare module BABYLON {
  53420. /**
  53421. * Block used to apply a dot product between 2 vectors
  53422. */
  53423. export class DotBlock extends NodeMaterialBlock {
  53424. /**
  53425. * Creates a new DotBlock
  53426. * @param name defines the block name
  53427. */
  53428. constructor(name: string);
  53429. /**
  53430. * Gets the current class name
  53431. * @returns the class name
  53432. */
  53433. getClassName(): string;
  53434. /**
  53435. * Gets the left operand input component
  53436. */
  53437. readonly left: NodeMaterialConnectionPoint;
  53438. /**
  53439. * Gets the right operand input component
  53440. */
  53441. readonly right: NodeMaterialConnectionPoint;
  53442. /**
  53443. * Gets the output component
  53444. */
  53445. readonly output: NodeMaterialConnectionPoint;
  53446. protected _buildBlock(state: NodeMaterialBuildState): this;
  53447. }
  53448. }
  53449. declare module BABYLON {
  53450. /**
  53451. * Block used to remap a float from a range to a new one
  53452. */
  53453. export class RemapBlock extends NodeMaterialBlock {
  53454. /**
  53455. * Gets or sets the source range
  53456. */
  53457. sourceRange: Vector2;
  53458. /**
  53459. * Gets or sets the target range
  53460. */
  53461. targetRange: Vector2;
  53462. /**
  53463. * Creates a new RemapBlock
  53464. * @param name defines the block name
  53465. */
  53466. constructor(name: string);
  53467. /**
  53468. * Gets the current class name
  53469. * @returns the class name
  53470. */
  53471. getClassName(): string;
  53472. /**
  53473. * Gets the input component
  53474. */
  53475. readonly input: NodeMaterialConnectionPoint;
  53476. /**
  53477. * Gets the output component
  53478. */
  53479. readonly output: NodeMaterialConnectionPoint;
  53480. protected _buildBlock(state: NodeMaterialBuildState): this;
  53481. protected _dumpPropertiesCode(): string;
  53482. serialize(): any;
  53483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53484. }
  53485. }
  53486. declare module BABYLON {
  53487. /**
  53488. * Block used to normalize a vector
  53489. */
  53490. export class NormalizeBlock extends NodeMaterialBlock {
  53491. /**
  53492. * Creates a new NormalizeBlock
  53493. * @param name defines the block name
  53494. */
  53495. constructor(name: string);
  53496. /**
  53497. * Gets the current class name
  53498. * @returns the class name
  53499. */
  53500. getClassName(): string;
  53501. /**
  53502. * Gets the input component
  53503. */
  53504. readonly input: NodeMaterialConnectionPoint;
  53505. /**
  53506. * Gets the output component
  53507. */
  53508. readonly output: NodeMaterialConnectionPoint;
  53509. protected _buildBlock(state: NodeMaterialBuildState): this;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * Operations supported by the Trigonometry block
  53515. */
  53516. export enum TrigonometryBlockOperations {
  53517. /** Cos */
  53518. Cos = 0,
  53519. /** Sin */
  53520. Sin = 1,
  53521. /** Abs */
  53522. Abs = 2,
  53523. /** Exp */
  53524. Exp = 3,
  53525. /** Exp2 */
  53526. Exp2 = 4,
  53527. /** Round */
  53528. Round = 5,
  53529. /** Floor */
  53530. Floor = 6,
  53531. /** Ceiling */
  53532. Ceiling = 7
  53533. }
  53534. /**
  53535. * Block used to apply trigonometry operation to floats
  53536. */
  53537. export class TrigonometryBlock extends NodeMaterialBlock {
  53538. /**
  53539. * Gets or sets the operation applied by the block
  53540. */
  53541. operation: TrigonometryBlockOperations;
  53542. /**
  53543. * Creates a new TrigonometryBlock
  53544. * @param name defines the block name
  53545. */
  53546. constructor(name: string);
  53547. /**
  53548. * Gets the current class name
  53549. * @returns the class name
  53550. */
  53551. getClassName(): string;
  53552. /**
  53553. * Gets the input component
  53554. */
  53555. readonly input: NodeMaterialConnectionPoint;
  53556. /**
  53557. * Gets the output component
  53558. */
  53559. readonly output: NodeMaterialConnectionPoint;
  53560. protected _buildBlock(state: NodeMaterialBuildState): this;
  53561. }
  53562. }
  53563. declare module BABYLON {
  53564. /**
  53565. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53566. */
  53567. export class ColorMergerBlock extends NodeMaterialBlock {
  53568. /**
  53569. * Create a new ColorMergerBlock
  53570. * @param name defines the block name
  53571. */
  53572. constructor(name: string);
  53573. /**
  53574. * Gets the current class name
  53575. * @returns the class name
  53576. */
  53577. getClassName(): string;
  53578. /**
  53579. * Gets the r component (input)
  53580. */
  53581. readonly r: NodeMaterialConnectionPoint;
  53582. /**
  53583. * Gets the g component (input)
  53584. */
  53585. readonly g: NodeMaterialConnectionPoint;
  53586. /**
  53587. * Gets the b component (input)
  53588. */
  53589. readonly b: NodeMaterialConnectionPoint;
  53590. /**
  53591. * Gets the a component (input)
  53592. */
  53593. readonly a: NodeMaterialConnectionPoint;
  53594. /**
  53595. * Gets the rgba component (output)
  53596. */
  53597. readonly rgba: NodeMaterialConnectionPoint;
  53598. /**
  53599. * Gets the rgb component (output)
  53600. */
  53601. readonly rgb: NodeMaterialConnectionPoint;
  53602. protected _buildBlock(state: NodeMaterialBuildState): this;
  53603. }
  53604. }
  53605. declare module BABYLON {
  53606. /**
  53607. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53608. */
  53609. export class VectorMergerBlock extends NodeMaterialBlock {
  53610. /**
  53611. * Create a new VectorMergerBlock
  53612. * @param name defines the block name
  53613. */
  53614. constructor(name: string);
  53615. /**
  53616. * Gets the current class name
  53617. * @returns the class name
  53618. */
  53619. getClassName(): string;
  53620. /**
  53621. * Gets the x component (input)
  53622. */
  53623. readonly x: NodeMaterialConnectionPoint;
  53624. /**
  53625. * Gets the y component (input)
  53626. */
  53627. readonly y: NodeMaterialConnectionPoint;
  53628. /**
  53629. * Gets the z component (input)
  53630. */
  53631. readonly z: NodeMaterialConnectionPoint;
  53632. /**
  53633. * Gets the w component (input)
  53634. */
  53635. readonly w: NodeMaterialConnectionPoint;
  53636. /**
  53637. * Gets the xyzw component (output)
  53638. */
  53639. readonly xyzw: NodeMaterialConnectionPoint;
  53640. /**
  53641. * Gets the xyz component (output)
  53642. */
  53643. readonly xyz: NodeMaterialConnectionPoint;
  53644. /**
  53645. * Gets the xy component (output)
  53646. */
  53647. readonly xy: NodeMaterialConnectionPoint;
  53648. protected _buildBlock(state: NodeMaterialBuildState): this;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /**
  53653. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53654. */
  53655. export class ColorSplitterBlock extends NodeMaterialBlock {
  53656. /**
  53657. * Create a new ColorSplitterBlock
  53658. * @param name defines the block name
  53659. */
  53660. constructor(name: string);
  53661. /**
  53662. * Gets the current class name
  53663. * @returns the class name
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Gets the rgba component (input)
  53668. */
  53669. readonly rgba: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the rgb component (input)
  53672. */
  53673. readonly rgbIn: NodeMaterialConnectionPoint;
  53674. /**
  53675. * Gets the rgb component (output)
  53676. */
  53677. readonly rgbOut: NodeMaterialConnectionPoint;
  53678. /**
  53679. * Gets the r component (output)
  53680. */
  53681. readonly r: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the g component (output)
  53684. */
  53685. readonly g: NodeMaterialConnectionPoint;
  53686. /**
  53687. * Gets the b component (output)
  53688. */
  53689. readonly b: NodeMaterialConnectionPoint;
  53690. /**
  53691. * Gets the a component (output)
  53692. */
  53693. readonly a: NodeMaterialConnectionPoint;
  53694. protected _inputRename(name: string): string;
  53695. protected _outputRename(name: string): string;
  53696. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53697. }
  53698. }
  53699. declare module BABYLON {
  53700. /**
  53701. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53702. */
  53703. export class VectorSplitterBlock extends NodeMaterialBlock {
  53704. /**
  53705. * Create a new VectorSplitterBlock
  53706. * @param name defines the block name
  53707. */
  53708. constructor(name: string);
  53709. /**
  53710. * Gets the current class name
  53711. * @returns the class name
  53712. */
  53713. getClassName(): string;
  53714. /**
  53715. * Gets the xyzw component (input)
  53716. */
  53717. readonly xyzw: NodeMaterialConnectionPoint;
  53718. /**
  53719. * Gets the xyz component (input)
  53720. */
  53721. readonly xyzIn: NodeMaterialConnectionPoint;
  53722. /**
  53723. * Gets the xy component (input)
  53724. */
  53725. readonly xyIn: NodeMaterialConnectionPoint;
  53726. /**
  53727. * Gets the xyz component (output)
  53728. */
  53729. readonly xyzOut: NodeMaterialConnectionPoint;
  53730. /**
  53731. * Gets the xy component (output)
  53732. */
  53733. readonly xyOut: NodeMaterialConnectionPoint;
  53734. /**
  53735. * Gets the x component (output)
  53736. */
  53737. readonly x: NodeMaterialConnectionPoint;
  53738. /**
  53739. * Gets the y component (output)
  53740. */
  53741. readonly y: NodeMaterialConnectionPoint;
  53742. /**
  53743. * Gets the z component (output)
  53744. */
  53745. readonly z: NodeMaterialConnectionPoint;
  53746. /**
  53747. * Gets the w component (output)
  53748. */
  53749. readonly w: NodeMaterialConnectionPoint;
  53750. protected _inputRename(name: string): string;
  53751. protected _outputRename(name: string): string;
  53752. protected _buildBlock(state: NodeMaterialBuildState): this;
  53753. }
  53754. }
  53755. declare module BABYLON {
  53756. /**
  53757. * Block used to lerp 2 values
  53758. */
  53759. export class LerpBlock extends NodeMaterialBlock {
  53760. /**
  53761. * Creates a new LerpBlock
  53762. * @param name defines the block name
  53763. */
  53764. constructor(name: string);
  53765. /**
  53766. * Gets the current class name
  53767. * @returns the class name
  53768. */
  53769. getClassName(): string;
  53770. /**
  53771. * Gets the left operand input component
  53772. */
  53773. readonly left: NodeMaterialConnectionPoint;
  53774. /**
  53775. * Gets the right operand input component
  53776. */
  53777. readonly right: NodeMaterialConnectionPoint;
  53778. /**
  53779. * Gets the gradient operand input component
  53780. */
  53781. readonly gradient: NodeMaterialConnectionPoint;
  53782. /**
  53783. * Gets the output component
  53784. */
  53785. readonly output: NodeMaterialConnectionPoint;
  53786. protected _buildBlock(state: NodeMaterialBuildState): this;
  53787. }
  53788. }
  53789. declare module BABYLON {
  53790. /**
  53791. * Block used to divide 2 vectors
  53792. */
  53793. export class DivideBlock extends NodeMaterialBlock {
  53794. /**
  53795. * Creates a new DivideBlock
  53796. * @param name defines the block name
  53797. */
  53798. constructor(name: string);
  53799. /**
  53800. * Gets the current class name
  53801. * @returns the class name
  53802. */
  53803. getClassName(): string;
  53804. /**
  53805. * Gets the left operand input component
  53806. */
  53807. readonly left: NodeMaterialConnectionPoint;
  53808. /**
  53809. * Gets the right operand input component
  53810. */
  53811. readonly right: NodeMaterialConnectionPoint;
  53812. /**
  53813. * Gets the output component
  53814. */
  53815. readonly output: NodeMaterialConnectionPoint;
  53816. protected _buildBlock(state: NodeMaterialBuildState): this;
  53817. }
  53818. }
  53819. declare module BABYLON {
  53820. /**
  53821. * Block used to subtract 2 vectors
  53822. */
  53823. export class SubtractBlock extends NodeMaterialBlock {
  53824. /**
  53825. * Creates a new SubtractBlock
  53826. * @param name defines the block name
  53827. */
  53828. constructor(name: string);
  53829. /**
  53830. * Gets the current class name
  53831. * @returns the class name
  53832. */
  53833. getClassName(): string;
  53834. /**
  53835. * Gets the left operand input component
  53836. */
  53837. readonly left: NodeMaterialConnectionPoint;
  53838. /**
  53839. * Gets the right operand input component
  53840. */
  53841. readonly right: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Gets the output component
  53844. */
  53845. readonly output: NodeMaterialConnectionPoint;
  53846. protected _buildBlock(state: NodeMaterialBuildState): this;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. /**
  53851. * Block used to step a value
  53852. */
  53853. export class StepBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Creates a new AddBlock
  53856. * @param name defines the block name
  53857. */
  53858. constructor(name: string);
  53859. /**
  53860. * Gets the current class name
  53861. * @returns the class name
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Gets the value operand input component
  53866. */
  53867. readonly value: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the edge operand input component
  53870. */
  53871. readonly edge: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the output component
  53874. */
  53875. readonly output: NodeMaterialConnectionPoint;
  53876. protected _buildBlock(state: NodeMaterialBuildState): this;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. /**
  53881. * Effect Render Options
  53882. */
  53883. export interface IEffectRendererOptions {
  53884. /**
  53885. * Defines the vertices positions.
  53886. */
  53887. positions?: number[];
  53888. /**
  53889. * Defines the indices.
  53890. */
  53891. indices?: number[];
  53892. }
  53893. /**
  53894. * Helper class to render one or more effects
  53895. */
  53896. export class EffectRenderer {
  53897. private engine;
  53898. private static _DefaultOptions;
  53899. private _vertexBuffers;
  53900. private _indexBuffer;
  53901. private _ringBufferIndex;
  53902. private _ringScreenBuffer;
  53903. private _fullscreenViewport;
  53904. private _getNextFrameBuffer;
  53905. /**
  53906. * Creates an effect renderer
  53907. * @param engine the engine to use for rendering
  53908. * @param options defines the options of the effect renderer
  53909. */
  53910. constructor(engine: Engine, options?: IEffectRendererOptions);
  53911. /**
  53912. * Sets the current viewport in normalized coordinates 0-1
  53913. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  53914. */
  53915. setViewport(viewport?: Viewport): void;
  53916. /**
  53917. * Sets the current effect wrapper to use during draw.
  53918. * The effect needs to be ready before calling this api.
  53919. * This also sets the default full screen position attribute.
  53920. * @param effectWrapper Defines the effect to draw with
  53921. */
  53922. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  53923. /**
  53924. * Draws a full screen quad.
  53925. */
  53926. draw(): void;
  53927. /**
  53928. * renders one or more effects to a specified texture
  53929. * @param effectWrappers list of effects to renderer
  53930. * @param outputTexture texture to draw to, if null it will render to the screen
  53931. */
  53932. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  53933. /**
  53934. * Disposes of the effect renderer
  53935. */
  53936. dispose(): void;
  53937. }
  53938. /**
  53939. * Options to create an EffectWrapper
  53940. */
  53941. interface EffectWrapperCreationOptions {
  53942. /**
  53943. * Engine to use to create the effect
  53944. */
  53945. engine: Engine;
  53946. /**
  53947. * Fragment shader for the effect
  53948. */
  53949. fragmentShader: string;
  53950. /**
  53951. * Vertex shader for the effect
  53952. */
  53953. vertexShader?: string;
  53954. /**
  53955. * Attributes to use in the shader
  53956. */
  53957. attributeNames?: Array<string>;
  53958. /**
  53959. * Uniforms to use in the shader
  53960. */
  53961. uniformNames?: Array<string>;
  53962. /**
  53963. * Texture sampler names to use in the shader
  53964. */
  53965. samplerNames?: Array<string>;
  53966. /**
  53967. * The friendly name of the effect displayed in Spector.
  53968. */
  53969. name?: string;
  53970. }
  53971. /**
  53972. * Wraps an effect to be used for rendering
  53973. */
  53974. export class EffectWrapper {
  53975. /**
  53976. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  53977. */
  53978. onApplyObservable: Observable<{}>;
  53979. /**
  53980. * The underlying effect
  53981. */
  53982. effect: Effect;
  53983. /**
  53984. * Creates an effect to be renderer
  53985. * @param creationOptions options to create the effect
  53986. */
  53987. constructor(creationOptions: EffectWrapperCreationOptions);
  53988. /**
  53989. * Disposes of the effect wrapper
  53990. */
  53991. dispose(): void;
  53992. }
  53993. }
  53994. declare module BABYLON {
  53995. /**
  53996. * Helper class to push actions to a pool of workers.
  53997. */
  53998. export class WorkerPool implements IDisposable {
  53999. private _workerInfos;
  54000. private _pendingActions;
  54001. /**
  54002. * Constructor
  54003. * @param workers Array of workers to use for actions
  54004. */
  54005. constructor(workers: Array<Worker>);
  54006. /**
  54007. * Terminates all workers and clears any pending actions.
  54008. */
  54009. dispose(): void;
  54010. /**
  54011. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54012. * pended until a worker has completed its action.
  54013. * @param action The action to perform. Call onComplete when the action is complete.
  54014. */
  54015. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54016. private _execute;
  54017. }
  54018. }
  54019. declare module BABYLON {
  54020. /**
  54021. * Configuration for Draco compression
  54022. */
  54023. export interface IDracoCompressionConfiguration {
  54024. /**
  54025. * Configuration for the decoder.
  54026. */
  54027. decoder: {
  54028. /**
  54029. * The url to the WebAssembly module.
  54030. */
  54031. wasmUrl?: string;
  54032. /**
  54033. * The url to the WebAssembly binary.
  54034. */
  54035. wasmBinaryUrl?: string;
  54036. /**
  54037. * The url to the fallback JavaScript module.
  54038. */
  54039. fallbackUrl?: string;
  54040. };
  54041. }
  54042. /**
  54043. * Draco compression (https://google.github.io/draco/)
  54044. *
  54045. * This class wraps the Draco module.
  54046. *
  54047. * **Encoder**
  54048. *
  54049. * The encoder is not currently implemented.
  54050. *
  54051. * **Decoder**
  54052. *
  54053. * 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.
  54054. *
  54055. * To update the configuration, use the following code:
  54056. * ```javascript
  54057. * DracoCompression.Configuration = {
  54058. * decoder: {
  54059. * wasmUrl: "<url to the WebAssembly library>",
  54060. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54061. * fallbackUrl: "<url to the fallback JavaScript library>",
  54062. * }
  54063. * };
  54064. * ```
  54065. *
  54066. * 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.
  54067. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54068. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54069. *
  54070. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54071. * ```javascript
  54072. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54073. * ```
  54074. *
  54075. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54076. */
  54077. export class DracoCompression implements IDisposable {
  54078. private _workerPoolPromise?;
  54079. private _decoderModulePromise?;
  54080. /**
  54081. * The configuration. Defaults to the following urls:
  54082. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54083. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54084. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54085. */
  54086. static Configuration: IDracoCompressionConfiguration;
  54087. /**
  54088. * Returns true if the decoder configuration is available.
  54089. */
  54090. static readonly DecoderAvailable: boolean;
  54091. /**
  54092. * Default number of workers to create when creating the draco compression object.
  54093. */
  54094. static DefaultNumWorkers: number;
  54095. private static GetDefaultNumWorkers;
  54096. private static _Default;
  54097. /**
  54098. * Default instance for the draco compression object.
  54099. */
  54100. static readonly Default: DracoCompression;
  54101. /**
  54102. * Constructor
  54103. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54104. */
  54105. constructor(numWorkers?: number);
  54106. /**
  54107. * Stop all async operations and release resources.
  54108. */
  54109. dispose(): void;
  54110. /**
  54111. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54112. * @returns a promise that resolves when ready
  54113. */
  54114. whenReadyAsync(): Promise<void>;
  54115. /**
  54116. * Decode Draco compressed mesh data to vertex data.
  54117. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54118. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54119. * @returns A promise that resolves with the decoded vertex data
  54120. */
  54121. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54122. [kind: string]: number;
  54123. }): Promise<VertexData>;
  54124. }
  54125. }
  54126. declare module BABYLON {
  54127. /**
  54128. * Class for building Constructive Solid Geometry
  54129. */
  54130. export class CSG {
  54131. private polygons;
  54132. /**
  54133. * The world matrix
  54134. */
  54135. matrix: Matrix;
  54136. /**
  54137. * Stores the position
  54138. */
  54139. position: Vector3;
  54140. /**
  54141. * Stores the rotation
  54142. */
  54143. rotation: Vector3;
  54144. /**
  54145. * Stores the rotation quaternion
  54146. */
  54147. rotationQuaternion: Nullable<Quaternion>;
  54148. /**
  54149. * Stores the scaling vector
  54150. */
  54151. scaling: Vector3;
  54152. /**
  54153. * Convert the Mesh to CSG
  54154. * @param mesh The Mesh to convert to CSG
  54155. * @returns A new CSG from the Mesh
  54156. */
  54157. static FromMesh(mesh: Mesh): CSG;
  54158. /**
  54159. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54160. * @param polygons Polygons used to construct a CSG solid
  54161. */
  54162. private static FromPolygons;
  54163. /**
  54164. * Clones, or makes a deep copy, of the CSG
  54165. * @returns A new CSG
  54166. */
  54167. clone(): CSG;
  54168. /**
  54169. * Unions this CSG with another CSG
  54170. * @param csg The CSG to union against this CSG
  54171. * @returns The unioned CSG
  54172. */
  54173. union(csg: CSG): CSG;
  54174. /**
  54175. * Unions this CSG with another CSG in place
  54176. * @param csg The CSG to union against this CSG
  54177. */
  54178. unionInPlace(csg: CSG): void;
  54179. /**
  54180. * Subtracts this CSG with another CSG
  54181. * @param csg The CSG to subtract against this CSG
  54182. * @returns A new CSG
  54183. */
  54184. subtract(csg: CSG): CSG;
  54185. /**
  54186. * Subtracts this CSG with another CSG in place
  54187. * @param csg The CSG to subtact against this CSG
  54188. */
  54189. subtractInPlace(csg: CSG): void;
  54190. /**
  54191. * Intersect this CSG with another CSG
  54192. * @param csg The CSG to intersect against this CSG
  54193. * @returns A new CSG
  54194. */
  54195. intersect(csg: CSG): CSG;
  54196. /**
  54197. * Intersects this CSG with another CSG in place
  54198. * @param csg The CSG to intersect against this CSG
  54199. */
  54200. intersectInPlace(csg: CSG): void;
  54201. /**
  54202. * Return a new CSG solid with solid and empty space switched. This solid is
  54203. * not modified.
  54204. * @returns A new CSG solid with solid and empty space switched
  54205. */
  54206. inverse(): CSG;
  54207. /**
  54208. * Inverses the CSG in place
  54209. */
  54210. inverseInPlace(): void;
  54211. /**
  54212. * This is used to keep meshes transformations so they can be restored
  54213. * when we build back a Babylon Mesh
  54214. * NB : All CSG operations are performed in world coordinates
  54215. * @param csg The CSG to copy the transform attributes from
  54216. * @returns This CSG
  54217. */
  54218. copyTransformAttributes(csg: CSG): CSG;
  54219. /**
  54220. * Build Raw mesh from CSG
  54221. * Coordinates here are in world space
  54222. * @param name The name of the mesh geometry
  54223. * @param scene The Scene
  54224. * @param keepSubMeshes Specifies if the submeshes should be kept
  54225. * @returns A new Mesh
  54226. */
  54227. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54228. /**
  54229. * Build Mesh from CSG taking material and transforms into account
  54230. * @param name The name of the Mesh
  54231. * @param material The material of the Mesh
  54232. * @param scene The Scene
  54233. * @param keepSubMeshes Specifies if submeshes should be kept
  54234. * @returns The new Mesh
  54235. */
  54236. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * Class used to create a trail following a mesh
  54242. */
  54243. export class TrailMesh extends Mesh {
  54244. private _generator;
  54245. private _autoStart;
  54246. private _running;
  54247. private _diameter;
  54248. private _length;
  54249. private _sectionPolygonPointsCount;
  54250. private _sectionVectors;
  54251. private _sectionNormalVectors;
  54252. private _beforeRenderObserver;
  54253. /**
  54254. * @constructor
  54255. * @param name The value used by scene.getMeshByName() to do a lookup.
  54256. * @param generator The mesh to generate a trail.
  54257. * @param scene The scene to add this mesh to.
  54258. * @param diameter Diameter of trailing mesh. Default is 1.
  54259. * @param length Length of trailing mesh. Default is 60.
  54260. * @param autoStart Automatically start trailing mesh. Default true.
  54261. */
  54262. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54263. /**
  54264. * "TrailMesh"
  54265. * @returns "TrailMesh"
  54266. */
  54267. getClassName(): string;
  54268. private _createMesh;
  54269. /**
  54270. * Start trailing mesh.
  54271. */
  54272. start(): void;
  54273. /**
  54274. * Stop trailing mesh.
  54275. */
  54276. stop(): void;
  54277. /**
  54278. * Update trailing mesh geometry.
  54279. */
  54280. update(): void;
  54281. /**
  54282. * Returns a new TrailMesh object.
  54283. * @param name is a string, the name given to the new mesh
  54284. * @param newGenerator use new generator object for cloned trail mesh
  54285. * @returns a new mesh
  54286. */
  54287. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54288. /**
  54289. * Serializes this trail mesh
  54290. * @param serializationObject object to write serialization to
  54291. */
  54292. serialize(serializationObject: any): void;
  54293. /**
  54294. * Parses a serialized trail mesh
  54295. * @param parsedMesh the serialized mesh
  54296. * @param scene the scene to create the trail mesh in
  54297. * @returns the created trail mesh
  54298. */
  54299. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54300. }
  54301. }
  54302. declare module BABYLON {
  54303. /**
  54304. * Class containing static functions to help procedurally build meshes
  54305. */
  54306. export class TiledBoxBuilder {
  54307. /**
  54308. * Creates a box mesh
  54309. * 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)
  54310. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54312. * * 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
  54313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54314. * @param name defines the name of the mesh
  54315. * @param options defines the options used to create the mesh
  54316. * @param scene defines the hosting scene
  54317. * @returns the box mesh
  54318. */
  54319. static CreateTiledBox(name: string, options: {
  54320. pattern?: number;
  54321. width?: number;
  54322. height?: number;
  54323. depth?: number;
  54324. tileSize?: number;
  54325. tileWidth?: number;
  54326. tileHeight?: number;
  54327. alignHorizontal?: number;
  54328. alignVertical?: number;
  54329. faceUV?: Vector4[];
  54330. faceColors?: Color4[];
  54331. sideOrientation?: number;
  54332. updatable?: boolean;
  54333. }, scene?: Nullable<Scene>): Mesh;
  54334. }
  54335. }
  54336. declare module BABYLON {
  54337. /**
  54338. * Class containing static functions to help procedurally build meshes
  54339. */
  54340. export class TorusKnotBuilder {
  54341. /**
  54342. * Creates a torus knot mesh
  54343. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54344. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54345. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54346. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54348. * * 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
  54349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54350. * @param name defines the name of the mesh
  54351. * @param options defines the options used to create the mesh
  54352. * @param scene defines the hosting scene
  54353. * @returns the torus knot mesh
  54354. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54355. */
  54356. static CreateTorusKnot(name: string, options: {
  54357. radius?: number;
  54358. tube?: number;
  54359. radialSegments?: number;
  54360. tubularSegments?: number;
  54361. p?: number;
  54362. q?: number;
  54363. updatable?: boolean;
  54364. sideOrientation?: number;
  54365. frontUVs?: Vector4;
  54366. backUVs?: Vector4;
  54367. }, scene: any): Mesh;
  54368. }
  54369. }
  54370. declare module BABYLON {
  54371. /**
  54372. * Polygon
  54373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54374. */
  54375. export class Polygon {
  54376. /**
  54377. * Creates a rectangle
  54378. * @param xmin bottom X coord
  54379. * @param ymin bottom Y coord
  54380. * @param xmax top X coord
  54381. * @param ymax top Y coord
  54382. * @returns points that make the resulting rectation
  54383. */
  54384. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54385. /**
  54386. * Creates a circle
  54387. * @param radius radius of circle
  54388. * @param cx scale in x
  54389. * @param cy scale in y
  54390. * @param numberOfSides number of sides that make up the circle
  54391. * @returns points that make the resulting circle
  54392. */
  54393. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54394. /**
  54395. * Creates a polygon from input string
  54396. * @param input Input polygon data
  54397. * @returns the parsed points
  54398. */
  54399. static Parse(input: string): Vector2[];
  54400. /**
  54401. * Starts building a polygon from x and y coordinates
  54402. * @param x x coordinate
  54403. * @param y y coordinate
  54404. * @returns the started path2
  54405. */
  54406. static StartingAt(x: number, y: number): Path2;
  54407. }
  54408. /**
  54409. * Builds a polygon
  54410. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54411. */
  54412. export class PolygonMeshBuilder {
  54413. private _points;
  54414. private _outlinepoints;
  54415. private _holes;
  54416. private _name;
  54417. private _scene;
  54418. private _epoints;
  54419. private _eholes;
  54420. private _addToepoint;
  54421. /**
  54422. * Babylon reference to the earcut plugin.
  54423. */
  54424. bjsEarcut: any;
  54425. /**
  54426. * Creates a PolygonMeshBuilder
  54427. * @param name name of the builder
  54428. * @param contours Path of the polygon
  54429. * @param scene scene to add to when creating the mesh
  54430. * @param earcutInjection can be used to inject your own earcut reference
  54431. */
  54432. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54433. /**
  54434. * Adds a whole within the polygon
  54435. * @param hole Array of points defining the hole
  54436. * @returns this
  54437. */
  54438. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54439. /**
  54440. * Creates the polygon
  54441. * @param updatable If the mesh should be updatable
  54442. * @param depth The depth of the mesh created
  54443. * @returns the created mesh
  54444. */
  54445. build(updatable?: boolean, depth?: number): Mesh;
  54446. /**
  54447. * Creates the polygon
  54448. * @param depth The depth of the mesh created
  54449. * @returns the created VertexData
  54450. */
  54451. buildVertexData(depth?: number): VertexData;
  54452. /**
  54453. * Adds a side to the polygon
  54454. * @param positions points that make the polygon
  54455. * @param normals normals of the polygon
  54456. * @param uvs uvs of the polygon
  54457. * @param indices indices of the polygon
  54458. * @param bounds bounds of the polygon
  54459. * @param points points of the polygon
  54460. * @param depth depth of the polygon
  54461. * @param flip flip of the polygon
  54462. */
  54463. private addSide;
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. /**
  54468. * Class containing static functions to help procedurally build meshes
  54469. */
  54470. export class PolygonBuilder {
  54471. /**
  54472. * Creates a polygon mesh
  54473. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54474. * * 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
  54475. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54477. * * 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)
  54478. * * Remember you can only change the shape positions, not their number when updating a polygon
  54479. * @param name defines the name of the mesh
  54480. * @param options defines the options used to create the mesh
  54481. * @param scene defines the hosting scene
  54482. * @param earcutInjection can be used to inject your own earcut reference
  54483. * @returns the polygon mesh
  54484. */
  54485. static CreatePolygon(name: string, options: {
  54486. shape: Vector3[];
  54487. holes?: Vector3[][];
  54488. depth?: number;
  54489. faceUV?: Vector4[];
  54490. faceColors?: Color4[];
  54491. updatable?: boolean;
  54492. sideOrientation?: number;
  54493. frontUVs?: Vector4;
  54494. backUVs?: Vector4;
  54495. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54496. /**
  54497. * Creates an extruded polygon mesh, with depth in the Y direction.
  54498. * * 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)
  54499. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54500. * @param name defines the name of the mesh
  54501. * @param options defines the options used to create the mesh
  54502. * @param scene defines the hosting scene
  54503. * @param earcutInjection can be used to inject your own earcut reference
  54504. * @returns the polygon mesh
  54505. */
  54506. static ExtrudePolygon(name: string, options: {
  54507. shape: Vector3[];
  54508. holes?: Vector3[][];
  54509. depth?: number;
  54510. faceUV?: Vector4[];
  54511. faceColors?: Color4[];
  54512. updatable?: boolean;
  54513. sideOrientation?: number;
  54514. frontUVs?: Vector4;
  54515. backUVs?: Vector4;
  54516. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54517. }
  54518. }
  54519. declare module BABYLON {
  54520. /**
  54521. * Class containing static functions to help procedurally build meshes
  54522. */
  54523. export class LatheBuilder {
  54524. /**
  54525. * Creates lathe mesh.
  54526. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54527. * * 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
  54528. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54529. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54530. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54531. * * 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
  54532. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54533. * * 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
  54534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54535. * * 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
  54536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54538. * @param name defines the name of the mesh
  54539. * @param options defines the options used to create the mesh
  54540. * @param scene defines the hosting scene
  54541. * @returns the lathe mesh
  54542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54543. */
  54544. static CreateLathe(name: string, options: {
  54545. shape: Vector3[];
  54546. radius?: number;
  54547. tessellation?: number;
  54548. clip?: number;
  54549. arc?: number;
  54550. closed?: boolean;
  54551. updatable?: boolean;
  54552. sideOrientation?: number;
  54553. frontUVs?: Vector4;
  54554. backUVs?: Vector4;
  54555. cap?: number;
  54556. invertUV?: boolean;
  54557. }, scene?: Nullable<Scene>): Mesh;
  54558. }
  54559. }
  54560. declare module BABYLON {
  54561. /**
  54562. * Class containing static functions to help procedurally build meshes
  54563. */
  54564. export class TiledPlaneBuilder {
  54565. /**
  54566. * Creates a tiled plane mesh
  54567. * * The parameter `pattern` will, depending on value, do nothing or
  54568. * * * flip (reflect about central vertical) alternate tiles across and up
  54569. * * * flip every tile on alternate rows
  54570. * * * rotate (180 degs) alternate tiles across and up
  54571. * * * rotate every tile on alternate rows
  54572. * * * flip and rotate alternate tiles across and up
  54573. * * * flip and rotate every tile on alternate rows
  54574. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54575. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54576. * * 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
  54577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54578. * * 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)
  54579. * * 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)
  54580. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54581. * @param name defines the name of the mesh
  54582. * @param options defines the options used to create the mesh
  54583. * @param scene defines the hosting scene
  54584. * @returns the box mesh
  54585. */
  54586. static CreateTiledPlane(name: string, options: {
  54587. pattern?: number;
  54588. tileSize?: number;
  54589. tileWidth?: number;
  54590. tileHeight?: number;
  54591. size?: number;
  54592. width?: number;
  54593. height?: number;
  54594. alignHorizontal?: number;
  54595. alignVertical?: number;
  54596. sideOrientation?: number;
  54597. frontUVs?: Vector4;
  54598. backUVs?: Vector4;
  54599. updatable?: boolean;
  54600. }, scene?: Nullable<Scene>): Mesh;
  54601. }
  54602. }
  54603. declare module BABYLON {
  54604. /**
  54605. * Class containing static functions to help procedurally build meshes
  54606. */
  54607. export class TubeBuilder {
  54608. /**
  54609. * Creates a tube mesh.
  54610. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54611. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54612. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54613. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54614. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54615. * * 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)
  54616. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54617. * * 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
  54618. * * 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
  54619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54620. * * 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
  54621. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54623. * @param name defines the name of the mesh
  54624. * @param options defines the options used to create the mesh
  54625. * @param scene defines the hosting scene
  54626. * @returns the tube mesh
  54627. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54628. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54629. */
  54630. static CreateTube(name: string, options: {
  54631. path: Vector3[];
  54632. radius?: number;
  54633. tessellation?: number;
  54634. radiusFunction?: {
  54635. (i: number, distance: number): number;
  54636. };
  54637. cap?: number;
  54638. arc?: number;
  54639. updatable?: boolean;
  54640. sideOrientation?: number;
  54641. frontUVs?: Vector4;
  54642. backUVs?: Vector4;
  54643. instance?: Mesh;
  54644. invertUV?: boolean;
  54645. }, scene?: Nullable<Scene>): Mesh;
  54646. }
  54647. }
  54648. declare module BABYLON {
  54649. /**
  54650. * Class containing static functions to help procedurally build meshes
  54651. */
  54652. export class IcoSphereBuilder {
  54653. /**
  54654. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54655. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54656. * * 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`)
  54657. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54658. * * 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
  54659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54660. * * 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
  54661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54662. * @param name defines the name of the mesh
  54663. * @param options defines the options used to create the mesh
  54664. * @param scene defines the hosting scene
  54665. * @returns the icosahedron mesh
  54666. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54667. */
  54668. static CreateIcoSphere(name: string, options: {
  54669. radius?: number;
  54670. radiusX?: number;
  54671. radiusY?: number;
  54672. radiusZ?: number;
  54673. flat?: boolean;
  54674. subdivisions?: number;
  54675. sideOrientation?: number;
  54676. frontUVs?: Vector4;
  54677. backUVs?: Vector4;
  54678. updatable?: boolean;
  54679. }, scene?: Nullable<Scene>): Mesh;
  54680. }
  54681. }
  54682. declare module BABYLON {
  54683. /**
  54684. * Class containing static functions to help procedurally build meshes
  54685. */
  54686. export class DecalBuilder {
  54687. /**
  54688. * Creates a decal mesh.
  54689. * 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
  54690. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54691. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54692. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54693. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54694. * @param name defines the name of the mesh
  54695. * @param sourceMesh defines the mesh where the decal must be applied
  54696. * @param options defines the options used to create the mesh
  54697. * @param scene defines the hosting scene
  54698. * @returns the decal mesh
  54699. * @see https://doc.babylonjs.com/how_to/decals
  54700. */
  54701. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54702. position?: Vector3;
  54703. normal?: Vector3;
  54704. size?: Vector3;
  54705. angle?: number;
  54706. }): Mesh;
  54707. }
  54708. }
  54709. declare module BABYLON {
  54710. /**
  54711. * Class containing static functions to help procedurally build meshes
  54712. */
  54713. export class MeshBuilder {
  54714. /**
  54715. * Creates a box mesh
  54716. * * The parameter `size` sets the size (float) of each box side (default 1)
  54717. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54718. * * 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)
  54719. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54721. * * 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
  54722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54723. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54724. * @param name defines the name of the mesh
  54725. * @param options defines the options used to create the mesh
  54726. * @param scene defines the hosting scene
  54727. * @returns the box mesh
  54728. */
  54729. static CreateBox(name: string, options: {
  54730. size?: number;
  54731. width?: number;
  54732. height?: number;
  54733. depth?: number;
  54734. faceUV?: Vector4[];
  54735. faceColors?: Color4[];
  54736. sideOrientation?: number;
  54737. frontUVs?: Vector4;
  54738. backUVs?: Vector4;
  54739. updatable?: boolean;
  54740. }, scene?: Nullable<Scene>): Mesh;
  54741. /**
  54742. * Creates a tiled box mesh
  54743. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54745. * @param name defines the name of the mesh
  54746. * @param options defines the options used to create the mesh
  54747. * @param scene defines the hosting scene
  54748. * @returns the tiled box mesh
  54749. */
  54750. static CreateTiledBox(name: string, options: {
  54751. pattern?: number;
  54752. size?: number;
  54753. width?: number;
  54754. height?: number;
  54755. depth: number;
  54756. tileSize?: number;
  54757. tileWidth?: number;
  54758. tileHeight?: number;
  54759. faceUV?: Vector4[];
  54760. faceColors?: Color4[];
  54761. alignHorizontal?: number;
  54762. alignVertical?: number;
  54763. sideOrientation?: number;
  54764. updatable?: boolean;
  54765. }, scene?: Nullable<Scene>): Mesh;
  54766. /**
  54767. * Creates a sphere mesh
  54768. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54769. * * 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`)
  54770. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54771. * * 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
  54772. * * 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)
  54773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54774. * * 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
  54775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54776. * @param name defines the name of the mesh
  54777. * @param options defines the options used to create the mesh
  54778. * @param scene defines the hosting scene
  54779. * @returns the sphere mesh
  54780. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54781. */
  54782. static CreateSphere(name: string, options: {
  54783. segments?: number;
  54784. diameter?: number;
  54785. diameterX?: number;
  54786. diameterY?: number;
  54787. diameterZ?: number;
  54788. arc?: number;
  54789. slice?: number;
  54790. sideOrientation?: number;
  54791. frontUVs?: Vector4;
  54792. backUVs?: Vector4;
  54793. updatable?: boolean;
  54794. }, scene?: Nullable<Scene>): Mesh;
  54795. /**
  54796. * Creates a plane polygonal mesh. By default, this is a disc
  54797. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54798. * * 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
  54799. * * 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
  54800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54801. * * 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
  54802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54803. * @param name defines the name of the mesh
  54804. * @param options defines the options used to create the mesh
  54805. * @param scene defines the hosting scene
  54806. * @returns the plane polygonal mesh
  54807. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54808. */
  54809. static CreateDisc(name: string, options: {
  54810. radius?: number;
  54811. tessellation?: number;
  54812. arc?: number;
  54813. updatable?: boolean;
  54814. sideOrientation?: number;
  54815. frontUVs?: Vector4;
  54816. backUVs?: Vector4;
  54817. }, scene?: Nullable<Scene>): Mesh;
  54818. /**
  54819. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54820. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54821. * * 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`)
  54822. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54823. * * 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
  54824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54825. * * 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
  54826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54827. * @param name defines the name of the mesh
  54828. * @param options defines the options used to create the mesh
  54829. * @param scene defines the hosting scene
  54830. * @returns the icosahedron mesh
  54831. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54832. */
  54833. static CreateIcoSphere(name: string, options: {
  54834. radius?: number;
  54835. radiusX?: number;
  54836. radiusY?: number;
  54837. radiusZ?: number;
  54838. flat?: boolean;
  54839. subdivisions?: number;
  54840. sideOrientation?: number;
  54841. frontUVs?: Vector4;
  54842. backUVs?: Vector4;
  54843. updatable?: boolean;
  54844. }, scene?: Nullable<Scene>): Mesh;
  54845. /**
  54846. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54847. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54848. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54849. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54850. * * 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
  54851. * * 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
  54852. * * 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
  54853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54854. * * 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
  54855. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54856. * * 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
  54857. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54858. * * 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
  54859. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54861. * @param name defines the name of the mesh
  54862. * @param options defines the options used to create the mesh
  54863. * @param scene defines the hosting scene
  54864. * @returns the ribbon mesh
  54865. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54866. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54867. */
  54868. static CreateRibbon(name: string, options: {
  54869. pathArray: Vector3[][];
  54870. closeArray?: boolean;
  54871. closePath?: boolean;
  54872. offset?: number;
  54873. updatable?: boolean;
  54874. sideOrientation?: number;
  54875. frontUVs?: Vector4;
  54876. backUVs?: Vector4;
  54877. instance?: Mesh;
  54878. invertUV?: boolean;
  54879. uvs?: Vector2[];
  54880. colors?: Color4[];
  54881. }, scene?: Nullable<Scene>): Mesh;
  54882. /**
  54883. * Creates a cylinder or a cone mesh
  54884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54886. * * 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.
  54887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54891. * * 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).
  54892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54893. * * 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).
  54894. * * 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
  54895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54896. * * 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
  54897. * * 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.
  54898. * * If `enclose` is false, a ring surface is one element.
  54899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54900. * * 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
  54901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54902. * * 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
  54903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54904. * @param name defines the name of the mesh
  54905. * @param options defines the options used to create the mesh
  54906. * @param scene defines the hosting scene
  54907. * @returns the cylinder mesh
  54908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54909. */
  54910. static CreateCylinder(name: string, options: {
  54911. height?: number;
  54912. diameterTop?: number;
  54913. diameterBottom?: number;
  54914. diameter?: number;
  54915. tessellation?: number;
  54916. subdivisions?: number;
  54917. arc?: number;
  54918. faceColors?: Color4[];
  54919. faceUV?: Vector4[];
  54920. updatable?: boolean;
  54921. hasRings?: boolean;
  54922. enclose?: boolean;
  54923. cap?: number;
  54924. sideOrientation?: number;
  54925. frontUVs?: Vector4;
  54926. backUVs?: Vector4;
  54927. }, scene?: Nullable<Scene>): Mesh;
  54928. /**
  54929. * Creates a torus mesh
  54930. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54931. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54932. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54934. * * 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
  54935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54936. * @param name defines the name of the mesh
  54937. * @param options defines the options used to create the mesh
  54938. * @param scene defines the hosting scene
  54939. * @returns the torus mesh
  54940. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54941. */
  54942. static CreateTorus(name: string, options: {
  54943. diameter?: number;
  54944. thickness?: number;
  54945. tessellation?: number;
  54946. updatable?: boolean;
  54947. sideOrientation?: number;
  54948. frontUVs?: Vector4;
  54949. backUVs?: Vector4;
  54950. }, scene?: Nullable<Scene>): Mesh;
  54951. /**
  54952. * Creates a torus knot mesh
  54953. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54954. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54955. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54956. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54958. * * 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
  54959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54960. * @param name defines the name of the mesh
  54961. * @param options defines the options used to create the mesh
  54962. * @param scene defines the hosting scene
  54963. * @returns the torus knot mesh
  54964. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54965. */
  54966. static CreateTorusKnot(name: string, options: {
  54967. radius?: number;
  54968. tube?: number;
  54969. radialSegments?: number;
  54970. tubularSegments?: number;
  54971. p?: number;
  54972. q?: number;
  54973. updatable?: boolean;
  54974. sideOrientation?: number;
  54975. frontUVs?: Vector4;
  54976. backUVs?: Vector4;
  54977. }, scene?: Nullable<Scene>): Mesh;
  54978. /**
  54979. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54980. * * 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
  54981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54982. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54983. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54984. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54985. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54986. * * 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
  54987. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54990. * @param name defines the name of the new line system
  54991. * @param options defines the options used to create the line system
  54992. * @param scene defines the hosting scene
  54993. * @returns a new line system mesh
  54994. */
  54995. static CreateLineSystem(name: string, options: {
  54996. lines: Vector3[][];
  54997. updatable?: boolean;
  54998. instance?: Nullable<LinesMesh>;
  54999. colors?: Nullable<Color4[][]>;
  55000. useVertexAlpha?: boolean;
  55001. }, scene: Nullable<Scene>): LinesMesh;
  55002. /**
  55003. * Creates a line mesh
  55004. * 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
  55005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55006. * * The parameter `points` is an array successive Vector3
  55007. * * 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
  55008. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55009. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55010. * * When updating an instance, remember that only point positions can change, not the number of points
  55011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55013. * @param name defines the name of the new line system
  55014. * @param options defines the options used to create the line system
  55015. * @param scene defines the hosting scene
  55016. * @returns a new line mesh
  55017. */
  55018. static CreateLines(name: string, options: {
  55019. points: Vector3[];
  55020. updatable?: boolean;
  55021. instance?: Nullable<LinesMesh>;
  55022. colors?: Color4[];
  55023. useVertexAlpha?: boolean;
  55024. }, scene?: Nullable<Scene>): LinesMesh;
  55025. /**
  55026. * Creates a dashed line mesh
  55027. * * 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
  55028. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55029. * * The parameter `points` is an array successive Vector3
  55030. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55031. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55032. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55033. * * 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
  55034. * * When updating an instance, remember that only point positions can change, not the number of points
  55035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55036. * @param name defines the name of the mesh
  55037. * @param options defines the options used to create the mesh
  55038. * @param scene defines the hosting scene
  55039. * @returns the dashed line mesh
  55040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55041. */
  55042. static CreateDashedLines(name: string, options: {
  55043. points: Vector3[];
  55044. dashSize?: number;
  55045. gapSize?: number;
  55046. dashNb?: number;
  55047. updatable?: boolean;
  55048. instance?: LinesMesh;
  55049. }, scene?: Nullable<Scene>): LinesMesh;
  55050. /**
  55051. * 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.
  55052. * * 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.
  55053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55054. * * 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.
  55055. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55056. * * 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
  55057. * * 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
  55058. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55060. * * 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
  55061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55063. * @param name defines the name of the mesh
  55064. * @param options defines the options used to create the mesh
  55065. * @param scene defines the hosting scene
  55066. * @returns the extruded shape mesh
  55067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55069. */
  55070. static ExtrudeShape(name: string, options: {
  55071. shape: Vector3[];
  55072. path: Vector3[];
  55073. scale?: number;
  55074. rotation?: number;
  55075. cap?: number;
  55076. updatable?: boolean;
  55077. sideOrientation?: number;
  55078. frontUVs?: Vector4;
  55079. backUVs?: Vector4;
  55080. instance?: Mesh;
  55081. invertUV?: boolean;
  55082. }, scene?: Nullable<Scene>): Mesh;
  55083. /**
  55084. * Creates an custom extruded shape mesh.
  55085. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55086. * * 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.
  55087. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55088. * * 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
  55089. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55090. * * 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
  55091. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55092. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55093. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55094. * * 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
  55095. * * 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
  55096. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55098. * * 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
  55099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55101. * @param name defines the name of the mesh
  55102. * @param options defines the options used to create the mesh
  55103. * @param scene defines the hosting scene
  55104. * @returns the custom extruded shape mesh
  55105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55108. */
  55109. static ExtrudeShapeCustom(name: string, options: {
  55110. shape: Vector3[];
  55111. path: Vector3[];
  55112. scaleFunction?: any;
  55113. rotationFunction?: any;
  55114. ribbonCloseArray?: boolean;
  55115. ribbonClosePath?: boolean;
  55116. cap?: number;
  55117. updatable?: boolean;
  55118. sideOrientation?: number;
  55119. frontUVs?: Vector4;
  55120. backUVs?: Vector4;
  55121. instance?: Mesh;
  55122. invertUV?: boolean;
  55123. }, scene?: Nullable<Scene>): Mesh;
  55124. /**
  55125. * Creates lathe mesh.
  55126. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55127. * * 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
  55128. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55129. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55130. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55131. * * 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
  55132. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55133. * * 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
  55134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55135. * * 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
  55136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55138. * @param name defines the name of the mesh
  55139. * @param options defines the options used to create the mesh
  55140. * @param scene defines the hosting scene
  55141. * @returns the lathe mesh
  55142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55143. */
  55144. static CreateLathe(name: string, options: {
  55145. shape: Vector3[];
  55146. radius?: number;
  55147. tessellation?: number;
  55148. clip?: number;
  55149. arc?: number;
  55150. closed?: boolean;
  55151. updatable?: boolean;
  55152. sideOrientation?: number;
  55153. frontUVs?: Vector4;
  55154. backUVs?: Vector4;
  55155. cap?: number;
  55156. invertUV?: boolean;
  55157. }, scene?: Nullable<Scene>): Mesh;
  55158. /**
  55159. * Creates a tiled plane mesh
  55160. * * You can set a limited pattern arrangement with the tiles
  55161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55162. * * 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
  55163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55164. * @param name defines the name of the mesh
  55165. * @param options defines the options used to create the mesh
  55166. * @param scene defines the hosting scene
  55167. * @returns the plane mesh
  55168. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55169. */
  55170. static CreateTiledPlane(name: string, options: {
  55171. pattern?: number;
  55172. tileSize?: number;
  55173. tileWidth?: number;
  55174. tileHeight?: number;
  55175. size?: number;
  55176. width?: number;
  55177. height?: number;
  55178. alignHorizontal?: number;
  55179. alignVertical?: number;
  55180. sideOrientation?: number;
  55181. frontUVs?: Vector4;
  55182. backUVs?: Vector4;
  55183. updatable?: boolean;
  55184. }, scene?: Nullable<Scene>): Mesh;
  55185. /**
  55186. * Creates a plane mesh
  55187. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55188. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55189. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55191. * * 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
  55192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55193. * @param name defines the name of the mesh
  55194. * @param options defines the options used to create the mesh
  55195. * @param scene defines the hosting scene
  55196. * @returns the plane mesh
  55197. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55198. */
  55199. static CreatePlane(name: string, options: {
  55200. size?: number;
  55201. width?: number;
  55202. height?: number;
  55203. sideOrientation?: number;
  55204. frontUVs?: Vector4;
  55205. backUVs?: Vector4;
  55206. updatable?: boolean;
  55207. sourcePlane?: Plane;
  55208. }, scene?: Nullable<Scene>): Mesh;
  55209. /**
  55210. * Creates a ground mesh
  55211. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55212. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55214. * @param name defines the name of the mesh
  55215. * @param options defines the options used to create the mesh
  55216. * @param scene defines the hosting scene
  55217. * @returns the ground mesh
  55218. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55219. */
  55220. static CreateGround(name: string, options: {
  55221. width?: number;
  55222. height?: number;
  55223. subdivisions?: number;
  55224. subdivisionsX?: number;
  55225. subdivisionsY?: number;
  55226. updatable?: boolean;
  55227. }, scene?: Nullable<Scene>): Mesh;
  55228. /**
  55229. * Creates a tiled ground mesh
  55230. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55231. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55232. * * 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
  55233. * * 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
  55234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55235. * @param name defines the name of the mesh
  55236. * @param options defines the options used to create the mesh
  55237. * @param scene defines the hosting scene
  55238. * @returns the tiled ground mesh
  55239. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55240. */
  55241. static CreateTiledGround(name: string, options: {
  55242. xmin: number;
  55243. zmin: number;
  55244. xmax: number;
  55245. zmax: number;
  55246. subdivisions?: {
  55247. w: number;
  55248. h: number;
  55249. };
  55250. precision?: {
  55251. w: number;
  55252. h: number;
  55253. };
  55254. updatable?: boolean;
  55255. }, scene?: Nullable<Scene>): Mesh;
  55256. /**
  55257. * Creates a ground mesh from a height map
  55258. * * The parameter `url` sets the URL of the height map image resource.
  55259. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55260. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55261. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55262. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55263. * * 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.
  55264. * * 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).
  55265. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55267. * @param name defines the name of the mesh
  55268. * @param url defines the url to the height map
  55269. * @param options defines the options used to create the mesh
  55270. * @param scene defines the hosting scene
  55271. * @returns the ground mesh
  55272. * @see https://doc.babylonjs.com/babylon101/height_map
  55273. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55274. */
  55275. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55276. width?: number;
  55277. height?: number;
  55278. subdivisions?: number;
  55279. minHeight?: number;
  55280. maxHeight?: number;
  55281. colorFilter?: Color3;
  55282. alphaFilter?: number;
  55283. updatable?: boolean;
  55284. onReady?: (mesh: GroundMesh) => void;
  55285. }, scene?: Nullable<Scene>): GroundMesh;
  55286. /**
  55287. * Creates a polygon mesh
  55288. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55289. * * 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
  55290. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55292. * * 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)
  55293. * * Remember you can only change the shape positions, not their number when updating a polygon
  55294. * @param name defines the name of the mesh
  55295. * @param options defines the options used to create the mesh
  55296. * @param scene defines the hosting scene
  55297. * @param earcutInjection can be used to inject your own earcut reference
  55298. * @returns the polygon mesh
  55299. */
  55300. static CreatePolygon(name: string, options: {
  55301. shape: Vector3[];
  55302. holes?: Vector3[][];
  55303. depth?: number;
  55304. faceUV?: Vector4[];
  55305. faceColors?: Color4[];
  55306. updatable?: boolean;
  55307. sideOrientation?: number;
  55308. frontUVs?: Vector4;
  55309. backUVs?: Vector4;
  55310. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55311. /**
  55312. * Creates an extruded polygon mesh, with depth in the Y direction.
  55313. * * 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)
  55314. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55315. * @param name defines the name of the mesh
  55316. * @param options defines the options used to create the mesh
  55317. * @param scene defines the hosting scene
  55318. * @param earcutInjection can be used to inject your own earcut reference
  55319. * @returns the polygon mesh
  55320. */
  55321. static ExtrudePolygon(name: string, options: {
  55322. shape: Vector3[];
  55323. holes?: Vector3[][];
  55324. depth?: number;
  55325. faceUV?: Vector4[];
  55326. faceColors?: Color4[];
  55327. updatable?: boolean;
  55328. sideOrientation?: number;
  55329. frontUVs?: Vector4;
  55330. backUVs?: Vector4;
  55331. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55332. /**
  55333. * Creates a tube mesh.
  55334. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55335. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55336. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55337. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55338. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55339. * * 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)
  55340. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55341. * * 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
  55342. * * 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
  55343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55344. * * 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
  55345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55347. * @param name defines the name of the mesh
  55348. * @param options defines the options used to create the mesh
  55349. * @param scene defines the hosting scene
  55350. * @returns the tube mesh
  55351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55352. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55353. */
  55354. static CreateTube(name: string, options: {
  55355. path: Vector3[];
  55356. radius?: number;
  55357. tessellation?: number;
  55358. radiusFunction?: {
  55359. (i: number, distance: number): number;
  55360. };
  55361. cap?: number;
  55362. arc?: number;
  55363. updatable?: boolean;
  55364. sideOrientation?: number;
  55365. frontUVs?: Vector4;
  55366. backUVs?: Vector4;
  55367. instance?: Mesh;
  55368. invertUV?: boolean;
  55369. }, scene?: Nullable<Scene>): Mesh;
  55370. /**
  55371. * Creates a polyhedron mesh
  55372. * * 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
  55373. * * The parameter `size` (positive float, default 1) sets the polygon size
  55374. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55375. * * 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`
  55376. * * 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
  55377. * * 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)`)
  55378. * * 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
  55379. * * 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
  55380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55381. * * 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
  55382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55383. * @param name defines the name of the mesh
  55384. * @param options defines the options used to create the mesh
  55385. * @param scene defines the hosting scene
  55386. * @returns the polyhedron mesh
  55387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55388. */
  55389. static CreatePolyhedron(name: string, options: {
  55390. type?: number;
  55391. size?: number;
  55392. sizeX?: number;
  55393. sizeY?: number;
  55394. sizeZ?: number;
  55395. custom?: any;
  55396. faceUV?: Vector4[];
  55397. faceColors?: Color4[];
  55398. flat?: boolean;
  55399. updatable?: boolean;
  55400. sideOrientation?: number;
  55401. frontUVs?: Vector4;
  55402. backUVs?: Vector4;
  55403. }, scene?: Nullable<Scene>): Mesh;
  55404. /**
  55405. * Creates a decal mesh.
  55406. * 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
  55407. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55408. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55409. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55410. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55411. * @param name defines the name of the mesh
  55412. * @param sourceMesh defines the mesh where the decal must be applied
  55413. * @param options defines the options used to create the mesh
  55414. * @param scene defines the hosting scene
  55415. * @returns the decal mesh
  55416. * @see https://doc.babylonjs.com/how_to/decals
  55417. */
  55418. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55419. position?: Vector3;
  55420. normal?: Vector3;
  55421. size?: Vector3;
  55422. angle?: number;
  55423. }): Mesh;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * A simplifier interface for future simplification implementations
  55429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55430. */
  55431. export interface ISimplifier {
  55432. /**
  55433. * Simplification of a given mesh according to the given settings.
  55434. * Since this requires computation, it is assumed that the function runs async.
  55435. * @param settings The settings of the simplification, including quality and distance
  55436. * @param successCallback A callback that will be called after the mesh was simplified.
  55437. * @param errorCallback in case of an error, this callback will be called. optional.
  55438. */
  55439. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55440. }
  55441. /**
  55442. * Expected simplification settings.
  55443. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55444. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55445. */
  55446. export interface ISimplificationSettings {
  55447. /**
  55448. * Gets or sets the expected quality
  55449. */
  55450. quality: number;
  55451. /**
  55452. * Gets or sets the distance when this optimized version should be used
  55453. */
  55454. distance: number;
  55455. /**
  55456. * Gets an already optimized mesh
  55457. */
  55458. optimizeMesh?: boolean;
  55459. }
  55460. /**
  55461. * Class used to specify simplification options
  55462. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55463. */
  55464. export class SimplificationSettings implements ISimplificationSettings {
  55465. /** expected quality */
  55466. quality: number;
  55467. /** distance when this optimized version should be used */
  55468. distance: number;
  55469. /** already optimized mesh */
  55470. optimizeMesh?: boolean | undefined;
  55471. /**
  55472. * Creates a SimplificationSettings
  55473. * @param quality expected quality
  55474. * @param distance distance when this optimized version should be used
  55475. * @param optimizeMesh already optimized mesh
  55476. */
  55477. constructor(
  55478. /** expected quality */
  55479. quality: number,
  55480. /** distance when this optimized version should be used */
  55481. distance: number,
  55482. /** already optimized mesh */
  55483. optimizeMesh?: boolean | undefined);
  55484. }
  55485. /**
  55486. * Interface used to define a simplification task
  55487. */
  55488. export interface ISimplificationTask {
  55489. /**
  55490. * Array of settings
  55491. */
  55492. settings: Array<ISimplificationSettings>;
  55493. /**
  55494. * Simplification type
  55495. */
  55496. simplificationType: SimplificationType;
  55497. /**
  55498. * Mesh to simplify
  55499. */
  55500. mesh: Mesh;
  55501. /**
  55502. * Callback called on success
  55503. */
  55504. successCallback?: () => void;
  55505. /**
  55506. * Defines if parallel processing can be used
  55507. */
  55508. parallelProcessing: boolean;
  55509. }
  55510. /**
  55511. * Queue used to order the simplification tasks
  55512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55513. */
  55514. export class SimplificationQueue {
  55515. private _simplificationArray;
  55516. /**
  55517. * Gets a boolean indicating that the process is still running
  55518. */
  55519. running: boolean;
  55520. /**
  55521. * Creates a new queue
  55522. */
  55523. constructor();
  55524. /**
  55525. * Adds a new simplification task
  55526. * @param task defines a task to add
  55527. */
  55528. addTask(task: ISimplificationTask): void;
  55529. /**
  55530. * Execute next task
  55531. */
  55532. executeNext(): void;
  55533. /**
  55534. * Execute a simplification task
  55535. * @param task defines the task to run
  55536. */
  55537. runSimplification(task: ISimplificationTask): void;
  55538. private getSimplifier;
  55539. }
  55540. /**
  55541. * The implemented types of simplification
  55542. * At the moment only Quadratic Error Decimation is implemented
  55543. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55544. */
  55545. export enum SimplificationType {
  55546. /** Quadratic error decimation */
  55547. QUADRATIC = 0
  55548. }
  55549. }
  55550. declare module BABYLON {
  55551. interface Scene {
  55552. /** @hidden (Backing field) */
  55553. _simplificationQueue: SimplificationQueue;
  55554. /**
  55555. * Gets or sets the simplification queue attached to the scene
  55556. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55557. */
  55558. simplificationQueue: SimplificationQueue;
  55559. }
  55560. interface Mesh {
  55561. /**
  55562. * Simplify the mesh according to the given array of settings.
  55563. * Function will return immediately and will simplify async
  55564. * @param settings a collection of simplification settings
  55565. * @param parallelProcessing should all levels calculate parallel or one after the other
  55566. * @param simplificationType the type of simplification to run
  55567. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55568. * @returns the current mesh
  55569. */
  55570. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55571. }
  55572. /**
  55573. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55574. * created in a scene
  55575. */
  55576. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55577. /**
  55578. * The component name helpfull to identify the component in the list of scene components.
  55579. */
  55580. readonly name: string;
  55581. /**
  55582. * The scene the component belongs to.
  55583. */
  55584. scene: Scene;
  55585. /**
  55586. * Creates a new instance of the component for the given scene
  55587. * @param scene Defines the scene to register the component in
  55588. */
  55589. constructor(scene: Scene);
  55590. /**
  55591. * Registers the component in a given scene
  55592. */
  55593. register(): void;
  55594. /**
  55595. * Rebuilds the elements related to this component in case of
  55596. * context lost for instance.
  55597. */
  55598. rebuild(): void;
  55599. /**
  55600. * Disposes the component and the associated ressources
  55601. */
  55602. dispose(): void;
  55603. private _beforeCameraUpdate;
  55604. }
  55605. }
  55606. declare module BABYLON {
  55607. /**
  55608. * Navigation plugin interface to add navigation constrained by a navigation mesh
  55609. */
  55610. export interface INavigationEnginePlugin {
  55611. /**
  55612. * plugin name
  55613. */
  55614. name: string;
  55615. /**
  55616. * Creates a navigation mesh
  55617. * @param meshes array of all the geometry used to compute the navigatio mesh
  55618. * @param parameters bunch of parameters used to filter geometry
  55619. */
  55620. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55621. /**
  55622. * Create a navigation mesh debug mesh
  55623. * @param scene is where the mesh will be added
  55624. * @returns debug display mesh
  55625. */
  55626. createDebugNavMesh(scene: Scene): Mesh;
  55627. /**
  55628. * Get a navigation mesh constrained position, closest to the parameter position
  55629. * @param position world position
  55630. * @returns the closest point to position constrained by the navigation mesh
  55631. */
  55632. getClosestPoint(position: Vector3): Vector3;
  55633. /**
  55634. * Get a navigation mesh constrained position, within a particular radius
  55635. * @param position world position
  55636. * @param maxRadius the maximum distance to the constrained world position
  55637. * @returns the closest point to position constrained by the navigation mesh
  55638. */
  55639. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55640. /**
  55641. * Compute the final position from a segment made of destination-position
  55642. * @param position world position
  55643. * @param destination world position
  55644. * @returns the resulting point along the navmesh
  55645. */
  55646. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55647. /**
  55648. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55649. * @param start world position
  55650. * @param end world position
  55651. * @returns array containing world position composing the path
  55652. */
  55653. computePath(start: Vector3, end: Vector3): Vector3[];
  55654. /**
  55655. * If this plugin is supported
  55656. * @returns true if plugin is supported
  55657. */
  55658. isSupported(): boolean;
  55659. /**
  55660. * Create a new Crowd so you can add agents
  55661. * @param maxAgents the maximum agent count in the crowd
  55662. * @param maxAgentRadius the maximum radius an agent can have
  55663. * @param scene to attach the crowd to
  55664. * @returns the crowd you can add agents to
  55665. */
  55666. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55667. /**
  55668. * Release all resources
  55669. */
  55670. dispose(): void;
  55671. }
  55672. /**
  55673. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  55674. */
  55675. export interface ICrowd {
  55676. /**
  55677. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55678. * You can attach anything to that node. The node position is updated in the scene update tick.
  55679. * @param pos world position that will be constrained by the navigation mesh
  55680. * @param parameters agent parameters
  55681. * @param transform hooked to the agent that will be update by the scene
  55682. * @returns agent index
  55683. */
  55684. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55685. /**
  55686. * Returns the agent position in world space
  55687. * @param index agent index returned by addAgent
  55688. * @returns world space position
  55689. */
  55690. getAgentPosition(index: number): Vector3;
  55691. /**
  55692. * Gets the agent velocity in world space
  55693. * @param index agent index returned by addAgent
  55694. * @returns world space velocity
  55695. */
  55696. getAgentVelocity(index: number): Vector3;
  55697. /**
  55698. * remove a particular agent previously created
  55699. * @param index agent index returned by addAgent
  55700. */
  55701. removeAgent(index: number): void;
  55702. /**
  55703. * get the list of all agents attached to this crowd
  55704. * @returns list of agent indices
  55705. */
  55706. getAgents(): number[];
  55707. /**
  55708. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55709. * @param deltaTime in seconds
  55710. */
  55711. update(deltaTime: number): void;
  55712. /**
  55713. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55714. * @param index agent index returned by addAgent
  55715. * @param destination targeted world position
  55716. */
  55717. agentGoto(index: number, destination: Vector3): void;
  55718. /**
  55719. * Release all resources
  55720. */
  55721. dispose(): void;
  55722. }
  55723. /**
  55724. * Configures an agent
  55725. */
  55726. export interface IAgentParameters {
  55727. /**
  55728. * Agent radius. [Limit: >= 0]
  55729. */
  55730. radius: number;
  55731. /**
  55732. * Agent height. [Limit: > 0]
  55733. */
  55734. height: number;
  55735. /**
  55736. * Maximum allowed acceleration. [Limit: >= 0]
  55737. */
  55738. maxAcceleration: number;
  55739. /**
  55740. * Maximum allowed speed. [Limit: >= 0]
  55741. */
  55742. maxSpeed: number;
  55743. /**
  55744. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  55745. */
  55746. collisionQueryRange: number;
  55747. /**
  55748. * The path visibility optimization range. [Limit: > 0]
  55749. */
  55750. pathOptimizationRange: number;
  55751. /**
  55752. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  55753. */
  55754. separationWeight: number;
  55755. }
  55756. /**
  55757. * Configures the navigation mesh creation
  55758. */
  55759. export interface INavMeshParameters {
  55760. /**
  55761. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  55762. */
  55763. cs: number;
  55764. /**
  55765. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  55766. */
  55767. ch: number;
  55768. /**
  55769. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  55770. */
  55771. walkableSlopeAngle: number;
  55772. /**
  55773. * Minimum floor to 'ceiling' height that will still allow the floor area to
  55774. * be considered walkable. [Limit: >= 3] [Units: vx]
  55775. */
  55776. walkableHeight: number;
  55777. /**
  55778. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  55779. */
  55780. walkableClimb: number;
  55781. /**
  55782. * The distance to erode/shrink the walkable area of the heightfield away from
  55783. * obstructions. [Limit: >=0] [Units: vx]
  55784. */
  55785. walkableRadius: number;
  55786. /**
  55787. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  55788. */
  55789. maxEdgeLen: number;
  55790. /**
  55791. * The maximum distance a simplfied contour's border edges should deviate
  55792. * the original raw contour. [Limit: >=0] [Units: vx]
  55793. */
  55794. maxSimplificationError: number;
  55795. /**
  55796. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  55797. */
  55798. minRegionArea: number;
  55799. /**
  55800. * Any regions with a span count smaller than this value will, if possible,
  55801. * be merged with larger regions. [Limit: >=0] [Units: vx]
  55802. */
  55803. mergeRegionArea: number;
  55804. /**
  55805. * The maximum number of vertices allowed for polygons generated during the
  55806. * contour to polygon conversion process. [Limit: >= 3]
  55807. */
  55808. maxVertsPerPoly: number;
  55809. /**
  55810. * Sets the sampling distance to use when generating the detail mesh.
  55811. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  55812. */
  55813. detailSampleDist: number;
  55814. /**
  55815. * The maximum distance the detail mesh surface should deviate from heightfield
  55816. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  55817. */
  55818. detailSampleMaxError: number;
  55819. }
  55820. }
  55821. declare module BABYLON {
  55822. /**
  55823. * RecastJS navigation plugin
  55824. */
  55825. export class RecastJSPlugin implements INavigationEnginePlugin {
  55826. /**
  55827. * Reference to the Recast library
  55828. */
  55829. bjsRECAST: any;
  55830. /**
  55831. * plugin name
  55832. */
  55833. name: string;
  55834. /**
  55835. * the first navmesh created. We might extend this to support multiple navmeshes
  55836. */
  55837. navMesh: any;
  55838. /**
  55839. * Initializes the recastJS plugin
  55840. * @param recastInjection can be used to inject your own recast reference
  55841. */
  55842. constructor(recastInjection?: any);
  55843. /**
  55844. * Creates a navigation mesh
  55845. * @param meshes array of all the geometry used to compute the navigatio mesh
  55846. * @param parameters bunch of parameters used to filter geometry
  55847. */
  55848. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  55849. /**
  55850. * Create a navigation mesh debug mesh
  55851. * @param scene is where the mesh will be added
  55852. * @returns debug display mesh
  55853. */
  55854. createDebugNavMesh(scene: Scene): Mesh;
  55855. /**
  55856. * Get a navigation mesh constrained position, closest to the parameter position
  55857. * @param position world position
  55858. * @returns the closest point to position constrained by the navigation mesh
  55859. */
  55860. getClosestPoint(position: Vector3): Vector3;
  55861. /**
  55862. * Get a navigation mesh constrained position, within a particular radius
  55863. * @param position world position
  55864. * @param maxRadius the maximum distance to the constrained world position
  55865. * @returns the closest point to position constrained by the navigation mesh
  55866. */
  55867. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  55868. /**
  55869. * Compute the final position from a segment made of destination-position
  55870. * @param position world position
  55871. * @param destination world position
  55872. * @returns the resulting point along the navmesh
  55873. */
  55874. moveAlong(position: Vector3, destination: Vector3): Vector3;
  55875. /**
  55876. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  55877. * @param start world position
  55878. * @param end world position
  55879. * @returns array containing world position composing the path
  55880. */
  55881. computePath(start: Vector3, end: Vector3): Vector3[];
  55882. /**
  55883. * Create a new Crowd so you can add agents
  55884. * @param maxAgents the maximum agent count in the crowd
  55885. * @param maxAgentRadius the maximum radius an agent can have
  55886. * @param scene to attach the crowd to
  55887. * @returns the crowd you can add agents to
  55888. */
  55889. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  55890. /**
  55891. * Disposes
  55892. */
  55893. dispose(): void;
  55894. /**
  55895. * If this plugin is supported
  55896. * @returns true if plugin is supported
  55897. */
  55898. isSupported(): boolean;
  55899. }
  55900. /**
  55901. * Recast detour crowd implementation
  55902. */
  55903. export class RecastJSCrowd implements ICrowd {
  55904. /**
  55905. * Recast/detour plugin
  55906. */
  55907. bjsRECASTPlugin: RecastJSPlugin;
  55908. /**
  55909. * Link to the detour crowd
  55910. */
  55911. recastCrowd: any;
  55912. /**
  55913. * One transform per agent
  55914. */
  55915. transforms: TransformNode[];
  55916. /**
  55917. * All agents created
  55918. */
  55919. agents: number[];
  55920. /**
  55921. * Link to the scene is kept to unregister the crowd from the scene
  55922. */
  55923. private _scene;
  55924. /**
  55925. * Observer for crowd updates
  55926. */
  55927. private _onBeforeAnimationsObserver;
  55928. /**
  55929. * Constructor
  55930. * @param plugin recastJS plugin
  55931. * @param maxAgents the maximum agent count in the crowd
  55932. * @param maxAgentRadius the maximum radius an agent can have
  55933. * @param scene to attach the crowd to
  55934. * @returns the crowd you can add agents to
  55935. */
  55936. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  55937. /**
  55938. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  55939. * You can attach anything to that node. The node position is updated in the scene update tick.
  55940. * @param pos world position that will be constrained by the navigation mesh
  55941. * @param parameters agent parameters
  55942. * @param transform hooked to the agent that will be update by the scene
  55943. * @returns agent index
  55944. */
  55945. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  55946. /**
  55947. * Returns the agent position in world space
  55948. * @param index agent index returned by addAgent
  55949. * @returns world space position
  55950. */
  55951. getAgentPosition(index: number): Vector3;
  55952. /**
  55953. * Returns the agent velocity in world space
  55954. * @param index agent index returned by addAgent
  55955. * @returns world space velocity
  55956. */
  55957. getAgentVelocity(index: number): Vector3;
  55958. /**
  55959. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  55960. * @param index agent index returned by addAgent
  55961. * @param destination targeted world position
  55962. */
  55963. agentGoto(index: number, destination: Vector3): void;
  55964. /**
  55965. * remove a particular agent previously created
  55966. * @param index agent index returned by addAgent
  55967. */
  55968. removeAgent(index: number): void;
  55969. /**
  55970. * get the list of all agents attached to this crowd
  55971. * @returns list of agent indices
  55972. */
  55973. getAgents(): number[];
  55974. /**
  55975. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  55976. * @param deltaTime in seconds
  55977. */
  55978. update(deltaTime: number): void;
  55979. /**
  55980. * Release all resources
  55981. */
  55982. dispose(): void;
  55983. }
  55984. }
  55985. declare module BABYLON {
  55986. /**
  55987. * Class used to enable access to IndexedDB
  55988. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55989. */
  55990. export class Database implements IOfflineProvider {
  55991. private _callbackManifestChecked;
  55992. private _currentSceneUrl;
  55993. private _db;
  55994. private _enableSceneOffline;
  55995. private _enableTexturesOffline;
  55996. private _manifestVersionFound;
  55997. private _mustUpdateRessources;
  55998. private _hasReachedQuota;
  55999. private _isSupported;
  56000. private _idbFactory;
  56001. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56002. private static IsUASupportingBlobStorage;
  56003. /**
  56004. * Gets a boolean indicating if Database storate is enabled (off by default)
  56005. */
  56006. static IDBStorageEnabled: boolean;
  56007. /**
  56008. * Gets a boolean indicating if scene must be saved in the database
  56009. */
  56010. readonly enableSceneOffline: boolean;
  56011. /**
  56012. * Gets a boolean indicating if textures must be saved in the database
  56013. */
  56014. readonly enableTexturesOffline: boolean;
  56015. /**
  56016. * Creates a new Database
  56017. * @param urlToScene defines the url to load the scene
  56018. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56019. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56020. */
  56021. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56022. private static _ParseURL;
  56023. private static _ReturnFullUrlLocation;
  56024. private _checkManifestFile;
  56025. /**
  56026. * Open the database and make it available
  56027. * @param successCallback defines the callback to call on success
  56028. * @param errorCallback defines the callback to call on error
  56029. */
  56030. open(successCallback: () => void, errorCallback: () => void): void;
  56031. /**
  56032. * Loads an image from the database
  56033. * @param url defines the url to load from
  56034. * @param image defines the target DOM image
  56035. */
  56036. loadImage(url: string, image: HTMLImageElement): void;
  56037. private _loadImageFromDBAsync;
  56038. private _saveImageIntoDBAsync;
  56039. private _checkVersionFromDB;
  56040. private _loadVersionFromDBAsync;
  56041. private _saveVersionIntoDBAsync;
  56042. /**
  56043. * Loads a file from database
  56044. * @param url defines the URL to load from
  56045. * @param sceneLoaded defines a callback to call on success
  56046. * @param progressCallBack defines a callback to call when progress changed
  56047. * @param errorCallback defines a callback to call on error
  56048. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56049. */
  56050. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56051. private _loadFileAsync;
  56052. private _saveFileAsync;
  56053. /**
  56054. * Validates if xhr data is correct
  56055. * @param xhr defines the request to validate
  56056. * @param dataType defines the expected data type
  56057. * @returns true if data is correct
  56058. */
  56059. private static _ValidateXHRData;
  56060. }
  56061. }
  56062. declare module BABYLON {
  56063. /** @hidden */
  56064. export var gpuUpdateParticlesPixelShader: {
  56065. name: string;
  56066. shader: string;
  56067. };
  56068. }
  56069. declare module BABYLON {
  56070. /** @hidden */
  56071. export var gpuUpdateParticlesVertexShader: {
  56072. name: string;
  56073. shader: string;
  56074. };
  56075. }
  56076. declare module BABYLON {
  56077. /** @hidden */
  56078. export var clipPlaneFragmentDeclaration2: {
  56079. name: string;
  56080. shader: string;
  56081. };
  56082. }
  56083. declare module BABYLON {
  56084. /** @hidden */
  56085. export var gpuRenderParticlesPixelShader: {
  56086. name: string;
  56087. shader: string;
  56088. };
  56089. }
  56090. declare module BABYLON {
  56091. /** @hidden */
  56092. export var clipPlaneVertexDeclaration2: {
  56093. name: string;
  56094. shader: string;
  56095. };
  56096. }
  56097. declare module BABYLON {
  56098. /** @hidden */
  56099. export var gpuRenderParticlesVertexShader: {
  56100. name: string;
  56101. shader: string;
  56102. };
  56103. }
  56104. declare module BABYLON {
  56105. /**
  56106. * This represents a GPU particle system in Babylon
  56107. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56108. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56109. */
  56110. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56111. /**
  56112. * The layer mask we are rendering the particles through.
  56113. */
  56114. layerMask: number;
  56115. private _capacity;
  56116. private _activeCount;
  56117. private _currentActiveCount;
  56118. private _accumulatedCount;
  56119. private _renderEffect;
  56120. private _updateEffect;
  56121. private _buffer0;
  56122. private _buffer1;
  56123. private _spriteBuffer;
  56124. private _updateVAO;
  56125. private _renderVAO;
  56126. private _targetIndex;
  56127. private _sourceBuffer;
  56128. private _targetBuffer;
  56129. private _engine;
  56130. private _currentRenderId;
  56131. private _started;
  56132. private _stopped;
  56133. private _timeDelta;
  56134. private _randomTexture;
  56135. private _randomTexture2;
  56136. private _attributesStrideSize;
  56137. private _updateEffectOptions;
  56138. private _randomTextureSize;
  56139. private _actualFrame;
  56140. private readonly _rawTextureWidth;
  56141. /**
  56142. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56143. */
  56144. static readonly IsSupported: boolean;
  56145. /**
  56146. * An event triggered when the system is disposed.
  56147. */
  56148. onDisposeObservable: Observable<GPUParticleSystem>;
  56149. /**
  56150. * Gets the maximum number of particles active at the same time.
  56151. * @returns The max number of active particles.
  56152. */
  56153. getCapacity(): number;
  56154. /**
  56155. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56156. * to override the particles.
  56157. */
  56158. forceDepthWrite: boolean;
  56159. /**
  56160. * Gets or set the number of active particles
  56161. */
  56162. activeParticleCount: number;
  56163. private _preWarmDone;
  56164. /**
  56165. * Is this system ready to be used/rendered
  56166. * @return true if the system is ready
  56167. */
  56168. isReady(): boolean;
  56169. /**
  56170. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56171. * @returns True if it has been started, otherwise false.
  56172. */
  56173. isStarted(): boolean;
  56174. /**
  56175. * Starts the particle system and begins to emit
  56176. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56177. */
  56178. start(delay?: number): void;
  56179. /**
  56180. * Stops the particle system.
  56181. */
  56182. stop(): void;
  56183. /**
  56184. * Remove all active particles
  56185. */
  56186. reset(): void;
  56187. /**
  56188. * Returns the string "GPUParticleSystem"
  56189. * @returns a string containing the class name
  56190. */
  56191. getClassName(): string;
  56192. private _colorGradientsTexture;
  56193. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56194. /**
  56195. * Adds a new color gradient
  56196. * @param gradient defines the gradient to use (between 0 and 1)
  56197. * @param color1 defines the color to affect to the specified gradient
  56198. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56199. * @returns the current particle system
  56200. */
  56201. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56202. /**
  56203. * Remove a specific color gradient
  56204. * @param gradient defines the gradient to remove
  56205. * @returns the current particle system
  56206. */
  56207. removeColorGradient(gradient: number): GPUParticleSystem;
  56208. private _angularSpeedGradientsTexture;
  56209. private _sizeGradientsTexture;
  56210. private _velocityGradientsTexture;
  56211. private _limitVelocityGradientsTexture;
  56212. private _dragGradientsTexture;
  56213. private _addFactorGradient;
  56214. /**
  56215. * Adds a new size gradient
  56216. * @param gradient defines the gradient to use (between 0 and 1)
  56217. * @param factor defines the size factor to affect to the specified gradient
  56218. * @returns the current particle system
  56219. */
  56220. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56221. /**
  56222. * Remove a specific size gradient
  56223. * @param gradient defines the gradient to remove
  56224. * @returns the current particle system
  56225. */
  56226. removeSizeGradient(gradient: number): GPUParticleSystem;
  56227. /**
  56228. * Adds a new angular speed gradient
  56229. * @param gradient defines the gradient to use (between 0 and 1)
  56230. * @param factor defines the angular speed to affect to the specified gradient
  56231. * @returns the current particle system
  56232. */
  56233. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56234. /**
  56235. * Remove a specific angular speed gradient
  56236. * @param gradient defines the gradient to remove
  56237. * @returns the current particle system
  56238. */
  56239. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56240. /**
  56241. * Adds a new velocity gradient
  56242. * @param gradient defines the gradient to use (between 0 and 1)
  56243. * @param factor defines the velocity to affect to the specified gradient
  56244. * @returns the current particle system
  56245. */
  56246. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56247. /**
  56248. * Remove a specific velocity gradient
  56249. * @param gradient defines the gradient to remove
  56250. * @returns the current particle system
  56251. */
  56252. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56253. /**
  56254. * Adds a new limit velocity gradient
  56255. * @param gradient defines the gradient to use (between 0 and 1)
  56256. * @param factor defines the limit velocity value to affect to the specified gradient
  56257. * @returns the current particle system
  56258. */
  56259. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56260. /**
  56261. * Remove a specific limit velocity gradient
  56262. * @param gradient defines the gradient to remove
  56263. * @returns the current particle system
  56264. */
  56265. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56266. /**
  56267. * Adds a new drag gradient
  56268. * @param gradient defines the gradient to use (between 0 and 1)
  56269. * @param factor defines the drag value to affect to the specified gradient
  56270. * @returns the current particle system
  56271. */
  56272. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56273. /**
  56274. * Remove a specific drag gradient
  56275. * @param gradient defines the gradient to remove
  56276. * @returns the current particle system
  56277. */
  56278. removeDragGradient(gradient: number): GPUParticleSystem;
  56279. /**
  56280. * Not supported by GPUParticleSystem
  56281. * @param gradient defines the gradient to use (between 0 and 1)
  56282. * @param factor defines the emit rate value to affect to the specified gradient
  56283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56284. * @returns the current particle system
  56285. */
  56286. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56287. /**
  56288. * Not supported by GPUParticleSystem
  56289. * @param gradient defines the gradient to remove
  56290. * @returns the current particle system
  56291. */
  56292. removeEmitRateGradient(gradient: number): IParticleSystem;
  56293. /**
  56294. * Not supported by GPUParticleSystem
  56295. * @param gradient defines the gradient to use (between 0 and 1)
  56296. * @param factor defines the start size value to affect to the specified gradient
  56297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56298. * @returns the current particle system
  56299. */
  56300. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56301. /**
  56302. * Not supported by GPUParticleSystem
  56303. * @param gradient defines the gradient to remove
  56304. * @returns the current particle system
  56305. */
  56306. removeStartSizeGradient(gradient: number): IParticleSystem;
  56307. /**
  56308. * Not supported by GPUParticleSystem
  56309. * @param gradient defines the gradient to use (between 0 and 1)
  56310. * @param min defines the color remap minimal range
  56311. * @param max defines the color remap maximal range
  56312. * @returns the current particle system
  56313. */
  56314. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56315. /**
  56316. * Not supported by GPUParticleSystem
  56317. * @param gradient defines the gradient to remove
  56318. * @returns the current particle system
  56319. */
  56320. removeColorRemapGradient(): IParticleSystem;
  56321. /**
  56322. * Not supported by GPUParticleSystem
  56323. * @param gradient defines the gradient to use (between 0 and 1)
  56324. * @param min defines the alpha remap minimal range
  56325. * @param max defines the alpha remap maximal range
  56326. * @returns the current particle system
  56327. */
  56328. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56329. /**
  56330. * Not supported by GPUParticleSystem
  56331. * @param gradient defines the gradient to remove
  56332. * @returns the current particle system
  56333. */
  56334. removeAlphaRemapGradient(): IParticleSystem;
  56335. /**
  56336. * Not supported by GPUParticleSystem
  56337. * @param gradient defines the gradient to use (between 0 and 1)
  56338. * @param color defines the color to affect to the specified gradient
  56339. * @returns the current particle system
  56340. */
  56341. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56342. /**
  56343. * Not supported by GPUParticleSystem
  56344. * @param gradient defines the gradient to remove
  56345. * @returns the current particle system
  56346. */
  56347. removeRampGradient(): IParticleSystem;
  56348. /**
  56349. * Not supported by GPUParticleSystem
  56350. * @returns the list of ramp gradients
  56351. */
  56352. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56353. /**
  56354. * Not supported by GPUParticleSystem
  56355. * Gets or sets a boolean indicating that ramp gradients must be used
  56356. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56357. */
  56358. useRampGradients: boolean;
  56359. /**
  56360. * Not supported by GPUParticleSystem
  56361. * @param gradient defines the gradient to use (between 0 and 1)
  56362. * @param factor defines the life time factor to affect to the specified gradient
  56363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56364. * @returns the current particle system
  56365. */
  56366. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56367. /**
  56368. * Not supported by GPUParticleSystem
  56369. * @param gradient defines the gradient to remove
  56370. * @returns the current particle system
  56371. */
  56372. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56373. /**
  56374. * Instantiates a GPU particle system.
  56375. * 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.
  56376. * @param name The name of the particle system
  56377. * @param options The options used to create the system
  56378. * @param scene The scene the particle system belongs to
  56379. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56380. */
  56381. constructor(name: string, options: Partial<{
  56382. capacity: number;
  56383. randomTextureSize: number;
  56384. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56385. protected _reset(): void;
  56386. private _createUpdateVAO;
  56387. private _createRenderVAO;
  56388. private _initialize;
  56389. /** @hidden */
  56390. _recreateUpdateEffect(): void;
  56391. /** @hidden */
  56392. _recreateRenderEffect(): void;
  56393. /**
  56394. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56395. * @param preWarm defines if we are in the pre-warmimg phase
  56396. */
  56397. animate(preWarm?: boolean): void;
  56398. private _createFactorGradientTexture;
  56399. private _createSizeGradientTexture;
  56400. private _createAngularSpeedGradientTexture;
  56401. private _createVelocityGradientTexture;
  56402. private _createLimitVelocityGradientTexture;
  56403. private _createDragGradientTexture;
  56404. private _createColorGradientTexture;
  56405. /**
  56406. * Renders the particle system in its current state
  56407. * @param preWarm defines if the system should only update the particles but not render them
  56408. * @returns the current number of particles
  56409. */
  56410. render(preWarm?: boolean): number;
  56411. /**
  56412. * Rebuilds the particle system
  56413. */
  56414. rebuild(): void;
  56415. private _releaseBuffers;
  56416. private _releaseVAOs;
  56417. /**
  56418. * Disposes the particle system and free the associated resources
  56419. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56420. */
  56421. dispose(disposeTexture?: boolean): void;
  56422. /**
  56423. * Clones the particle system.
  56424. * @param name The name of the cloned object
  56425. * @param newEmitter The new emitter to use
  56426. * @returns the cloned particle system
  56427. */
  56428. clone(name: string, newEmitter: any): GPUParticleSystem;
  56429. /**
  56430. * Serializes the particle system to a JSON object.
  56431. * @returns the JSON object
  56432. */
  56433. serialize(): any;
  56434. /**
  56435. * Parses a JSON object to create a GPU particle system.
  56436. * @param parsedParticleSystem The JSON object to parse
  56437. * @param scene The scene to create the particle system in
  56438. * @param rootUrl The root url to use to load external dependencies like texture
  56439. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56440. * @returns the parsed GPU particle system
  56441. */
  56442. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56443. }
  56444. }
  56445. declare module BABYLON {
  56446. /**
  56447. * Represents a set of particle systems working together to create a specific effect
  56448. */
  56449. export class ParticleSystemSet implements IDisposable {
  56450. private _emitterCreationOptions;
  56451. private _emitterNode;
  56452. /**
  56453. * Gets the particle system list
  56454. */
  56455. systems: IParticleSystem[];
  56456. /**
  56457. * Gets the emitter node used with this set
  56458. */
  56459. readonly emitterNode: Nullable<TransformNode>;
  56460. /**
  56461. * Creates a new emitter mesh as a sphere
  56462. * @param options defines the options used to create the sphere
  56463. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56464. * @param scene defines the hosting scene
  56465. */
  56466. setEmitterAsSphere(options: {
  56467. diameter: number;
  56468. segments: number;
  56469. color: Color3;
  56470. }, renderingGroupId: number, scene: Scene): void;
  56471. /**
  56472. * Starts all particle systems of the set
  56473. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56474. */
  56475. start(emitter?: AbstractMesh): void;
  56476. /**
  56477. * Release all associated resources
  56478. */
  56479. dispose(): void;
  56480. /**
  56481. * Serialize the set into a JSON compatible object
  56482. * @returns a JSON compatible representation of the set
  56483. */
  56484. serialize(): any;
  56485. /**
  56486. * Parse a new ParticleSystemSet from a serialized source
  56487. * @param data defines a JSON compatible representation of the set
  56488. * @param scene defines the hosting scene
  56489. * @param gpu defines if we want GPU particles or CPU particles
  56490. * @returns a new ParticleSystemSet
  56491. */
  56492. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56493. }
  56494. }
  56495. declare module BABYLON {
  56496. /**
  56497. * This class is made for on one-liner static method to help creating particle system set.
  56498. */
  56499. export class ParticleHelper {
  56500. /**
  56501. * Gets or sets base Assets URL
  56502. */
  56503. static BaseAssetsUrl: string;
  56504. /**
  56505. * Create a default particle system that you can tweak
  56506. * @param emitter defines the emitter to use
  56507. * @param capacity defines the system capacity (default is 500 particles)
  56508. * @param scene defines the hosting scene
  56509. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56510. * @returns the new Particle system
  56511. */
  56512. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56513. /**
  56514. * This is the main static method (one-liner) of this helper to create different particle systems
  56515. * @param type This string represents the type to the particle system to create
  56516. * @param scene The scene where the particle system should live
  56517. * @param gpu If the system will use gpu
  56518. * @returns the ParticleSystemSet created
  56519. */
  56520. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56521. /**
  56522. * Static function used to export a particle system to a ParticleSystemSet variable.
  56523. * Please note that the emitter shape is not exported
  56524. * @param systems defines the particle systems to export
  56525. * @returns the created particle system set
  56526. */
  56527. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56528. }
  56529. }
  56530. declare module BABYLON {
  56531. interface Engine {
  56532. /**
  56533. * Create an effect to use with particle systems.
  56534. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56535. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56536. * @param uniformsNames defines a list of attribute names
  56537. * @param samplers defines an array of string used to represent textures
  56538. * @param defines defines the string containing the defines to use to compile the shaders
  56539. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56540. * @param onCompiled defines a function to call when the effect creation is successful
  56541. * @param onError defines a function to call when the effect creation has failed
  56542. * @returns the new Effect
  56543. */
  56544. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56545. }
  56546. interface Mesh {
  56547. /**
  56548. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56549. * @returns an array of IParticleSystem
  56550. */
  56551. getEmittedParticleSystems(): IParticleSystem[];
  56552. /**
  56553. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56554. * @returns an array of IParticleSystem
  56555. */
  56556. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56557. }
  56558. /**
  56559. * @hidden
  56560. */
  56561. export var _IDoNeedToBeInTheBuild: number;
  56562. }
  56563. declare module BABYLON {
  56564. interface Scene {
  56565. /** @hidden (Backing field) */
  56566. _physicsEngine: Nullable<IPhysicsEngine>;
  56567. /**
  56568. * Gets the current physics engine
  56569. * @returns a IPhysicsEngine or null if none attached
  56570. */
  56571. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56572. /**
  56573. * Enables physics to the current scene
  56574. * @param gravity defines the scene's gravity for the physics engine
  56575. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56576. * @return a boolean indicating if the physics engine was initialized
  56577. */
  56578. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56579. /**
  56580. * Disables and disposes the physics engine associated with the scene
  56581. */
  56582. disablePhysicsEngine(): void;
  56583. /**
  56584. * Gets a boolean indicating if there is an active physics engine
  56585. * @returns a boolean indicating if there is an active physics engine
  56586. */
  56587. isPhysicsEnabled(): boolean;
  56588. /**
  56589. * Deletes a physics compound impostor
  56590. * @param compound defines the compound to delete
  56591. */
  56592. deleteCompoundImpostor(compound: any): void;
  56593. /**
  56594. * An event triggered when physic simulation is about to be run
  56595. */
  56596. onBeforePhysicsObservable: Observable<Scene>;
  56597. /**
  56598. * An event triggered when physic simulation has been done
  56599. */
  56600. onAfterPhysicsObservable: Observable<Scene>;
  56601. }
  56602. interface AbstractMesh {
  56603. /** @hidden */
  56604. _physicsImpostor: Nullable<PhysicsImpostor>;
  56605. /**
  56606. * Gets or sets impostor used for physic simulation
  56607. * @see http://doc.babylonjs.com/features/physics_engine
  56608. */
  56609. physicsImpostor: Nullable<PhysicsImpostor>;
  56610. /**
  56611. * Gets the current physics impostor
  56612. * @see http://doc.babylonjs.com/features/physics_engine
  56613. * @returns a physics impostor or null
  56614. */
  56615. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56616. /** Apply a physic impulse to the mesh
  56617. * @param force defines the force to apply
  56618. * @param contactPoint defines where to apply the force
  56619. * @returns the current mesh
  56620. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56621. */
  56622. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56623. /**
  56624. * Creates a physic joint between two meshes
  56625. * @param otherMesh defines the other mesh to use
  56626. * @param pivot1 defines the pivot to use on this mesh
  56627. * @param pivot2 defines the pivot to use on the other mesh
  56628. * @param options defines additional options (can be plugin dependent)
  56629. * @returns the current mesh
  56630. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56631. */
  56632. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56633. /** @hidden */
  56634. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56635. }
  56636. /**
  56637. * Defines the physics engine scene component responsible to manage a physics engine
  56638. */
  56639. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56640. /**
  56641. * The component name helpful to identify the component in the list of scene components.
  56642. */
  56643. readonly name: string;
  56644. /**
  56645. * The scene the component belongs to.
  56646. */
  56647. scene: Scene;
  56648. /**
  56649. * Creates a new instance of the component for the given scene
  56650. * @param scene Defines the scene to register the component in
  56651. */
  56652. constructor(scene: Scene);
  56653. /**
  56654. * Registers the component in a given scene
  56655. */
  56656. register(): void;
  56657. /**
  56658. * Rebuilds the elements related to this component in case of
  56659. * context lost for instance.
  56660. */
  56661. rebuild(): void;
  56662. /**
  56663. * Disposes the component and the associated ressources
  56664. */
  56665. dispose(): void;
  56666. }
  56667. }
  56668. declare module BABYLON {
  56669. /**
  56670. * A helper for physics simulations
  56671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56672. */
  56673. export class PhysicsHelper {
  56674. private _scene;
  56675. private _physicsEngine;
  56676. /**
  56677. * Initializes the Physics helper
  56678. * @param scene Babylon.js scene
  56679. */
  56680. constructor(scene: Scene);
  56681. /**
  56682. * Applies a radial explosion impulse
  56683. * @param origin the origin of the explosion
  56684. * @param radiusOrEventOptions the radius or the options of radial explosion
  56685. * @param strength the explosion strength
  56686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56687. * @returns A physics radial explosion event, or null
  56688. */
  56689. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56690. /**
  56691. * Applies a radial explosion force
  56692. * @param origin the origin of the explosion
  56693. * @param radiusOrEventOptions the radius or the options of radial explosion
  56694. * @param strength the explosion strength
  56695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56696. * @returns A physics radial explosion event, or null
  56697. */
  56698. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56699. /**
  56700. * Creates a gravitational field
  56701. * @param origin the origin of the explosion
  56702. * @param radiusOrEventOptions the radius or the options of radial explosion
  56703. * @param strength the explosion strength
  56704. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56705. * @returns A physics gravitational field event, or null
  56706. */
  56707. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56708. /**
  56709. * Creates a physics updraft event
  56710. * @param origin the origin of the updraft
  56711. * @param radiusOrEventOptions the radius or the options of the updraft
  56712. * @param strength the strength of the updraft
  56713. * @param height the height of the updraft
  56714. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56715. * @returns A physics updraft event, or null
  56716. */
  56717. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56718. /**
  56719. * Creates a physics vortex event
  56720. * @param origin the of the vortex
  56721. * @param radiusOrEventOptions the radius or the options of the vortex
  56722. * @param strength the strength of the vortex
  56723. * @param height the height of the vortex
  56724. * @returns a Physics vortex event, or null
  56725. * A physics vortex event or null
  56726. */
  56727. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56728. }
  56729. /**
  56730. * Represents a physics radial explosion event
  56731. */
  56732. class PhysicsRadialExplosionEvent {
  56733. private _scene;
  56734. private _options;
  56735. private _sphere;
  56736. private _dataFetched;
  56737. /**
  56738. * Initializes a radial explosioin event
  56739. * @param _scene BabylonJS scene
  56740. * @param _options The options for the vortex event
  56741. */
  56742. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56743. /**
  56744. * Returns the data related to the radial explosion event (sphere).
  56745. * @returns The radial explosion event data
  56746. */
  56747. getData(): PhysicsRadialExplosionEventData;
  56748. /**
  56749. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56750. * @param impostor A physics imposter
  56751. * @param origin the origin of the explosion
  56752. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56753. */
  56754. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56755. /**
  56756. * Triggers affecterd impostors callbacks
  56757. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56758. */
  56759. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56760. /**
  56761. * Disposes the sphere.
  56762. * @param force Specifies if the sphere should be disposed by force
  56763. */
  56764. dispose(force?: boolean): void;
  56765. /*** Helpers ***/
  56766. private _prepareSphere;
  56767. private _intersectsWithSphere;
  56768. }
  56769. /**
  56770. * Represents a gravitational field event
  56771. */
  56772. class PhysicsGravitationalFieldEvent {
  56773. private _physicsHelper;
  56774. private _scene;
  56775. private _origin;
  56776. private _options;
  56777. private _tickCallback;
  56778. private _sphere;
  56779. private _dataFetched;
  56780. /**
  56781. * Initializes the physics gravitational field event
  56782. * @param _physicsHelper A physics helper
  56783. * @param _scene BabylonJS scene
  56784. * @param _origin The origin position of the gravitational field event
  56785. * @param _options The options for the vortex event
  56786. */
  56787. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56788. /**
  56789. * Returns the data related to the gravitational field event (sphere).
  56790. * @returns A gravitational field event
  56791. */
  56792. getData(): PhysicsGravitationalFieldEventData;
  56793. /**
  56794. * Enables the gravitational field.
  56795. */
  56796. enable(): void;
  56797. /**
  56798. * Disables the gravitational field.
  56799. */
  56800. disable(): void;
  56801. /**
  56802. * Disposes the sphere.
  56803. * @param force The force to dispose from the gravitational field event
  56804. */
  56805. dispose(force?: boolean): void;
  56806. private _tick;
  56807. }
  56808. /**
  56809. * Represents a physics updraft event
  56810. */
  56811. class PhysicsUpdraftEvent {
  56812. private _scene;
  56813. private _origin;
  56814. private _options;
  56815. private _physicsEngine;
  56816. private _originTop;
  56817. private _originDirection;
  56818. private _tickCallback;
  56819. private _cylinder;
  56820. private _cylinderPosition;
  56821. private _dataFetched;
  56822. /**
  56823. * Initializes the physics updraft event
  56824. * @param _scene BabylonJS scene
  56825. * @param _origin The origin position of the updraft
  56826. * @param _options The options for the updraft event
  56827. */
  56828. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56829. /**
  56830. * Returns the data related to the updraft event (cylinder).
  56831. * @returns A physics updraft event
  56832. */
  56833. getData(): PhysicsUpdraftEventData;
  56834. /**
  56835. * Enables the updraft.
  56836. */
  56837. enable(): void;
  56838. /**
  56839. * Disables the updraft.
  56840. */
  56841. disable(): void;
  56842. /**
  56843. * Disposes the cylinder.
  56844. * @param force Specifies if the updraft should be disposed by force
  56845. */
  56846. dispose(force?: boolean): void;
  56847. private getImpostorHitData;
  56848. private _tick;
  56849. /*** Helpers ***/
  56850. private _prepareCylinder;
  56851. private _intersectsWithCylinder;
  56852. }
  56853. /**
  56854. * Represents a physics vortex event
  56855. */
  56856. class PhysicsVortexEvent {
  56857. private _scene;
  56858. private _origin;
  56859. private _options;
  56860. private _physicsEngine;
  56861. private _originTop;
  56862. private _tickCallback;
  56863. private _cylinder;
  56864. private _cylinderPosition;
  56865. private _dataFetched;
  56866. /**
  56867. * Initializes the physics vortex event
  56868. * @param _scene The BabylonJS scene
  56869. * @param _origin The origin position of the vortex
  56870. * @param _options The options for the vortex event
  56871. */
  56872. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56873. /**
  56874. * Returns the data related to the vortex event (cylinder).
  56875. * @returns The physics vortex event data
  56876. */
  56877. getData(): PhysicsVortexEventData;
  56878. /**
  56879. * Enables the vortex.
  56880. */
  56881. enable(): void;
  56882. /**
  56883. * Disables the cortex.
  56884. */
  56885. disable(): void;
  56886. /**
  56887. * Disposes the sphere.
  56888. * @param force
  56889. */
  56890. dispose(force?: boolean): void;
  56891. private getImpostorHitData;
  56892. private _tick;
  56893. /*** Helpers ***/
  56894. private _prepareCylinder;
  56895. private _intersectsWithCylinder;
  56896. }
  56897. /**
  56898. * Options fot the radial explosion event
  56899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56900. */
  56901. export class PhysicsRadialExplosionEventOptions {
  56902. /**
  56903. * The radius of the sphere for the radial explosion.
  56904. */
  56905. radius: number;
  56906. /**
  56907. * The strenth of the explosion.
  56908. */
  56909. strength: number;
  56910. /**
  56911. * The strenght of the force in correspondence to the distance of the affected object
  56912. */
  56913. falloff: PhysicsRadialImpulseFalloff;
  56914. /**
  56915. * Sphere options for the radial explosion.
  56916. */
  56917. sphere: {
  56918. segments: number;
  56919. diameter: number;
  56920. };
  56921. /**
  56922. * Sphere options for the radial explosion.
  56923. */
  56924. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56925. }
  56926. /**
  56927. * Options fot the updraft event
  56928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56929. */
  56930. export class PhysicsUpdraftEventOptions {
  56931. /**
  56932. * The radius of the cylinder for the vortex
  56933. */
  56934. radius: number;
  56935. /**
  56936. * The strenth of the updraft.
  56937. */
  56938. strength: number;
  56939. /**
  56940. * The height of the cylinder for the updraft.
  56941. */
  56942. height: number;
  56943. /**
  56944. * The mode for the the updraft.
  56945. */
  56946. updraftMode: PhysicsUpdraftMode;
  56947. }
  56948. /**
  56949. * Options fot the vortex event
  56950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56951. */
  56952. export class PhysicsVortexEventOptions {
  56953. /**
  56954. * The radius of the cylinder for the vortex
  56955. */
  56956. radius: number;
  56957. /**
  56958. * The strenth of the vortex.
  56959. */
  56960. strength: number;
  56961. /**
  56962. * The height of the cylinder for the vortex.
  56963. */
  56964. height: number;
  56965. /**
  56966. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56967. */
  56968. centripetalForceThreshold: number;
  56969. /**
  56970. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56971. */
  56972. centripetalForceMultiplier: number;
  56973. /**
  56974. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56975. */
  56976. centrifugalForceMultiplier: number;
  56977. /**
  56978. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56979. */
  56980. updraftForceMultiplier: number;
  56981. }
  56982. /**
  56983. * The strenght of the force in correspondence to the distance of the affected object
  56984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56985. */
  56986. export enum PhysicsRadialImpulseFalloff {
  56987. /** Defines that impulse is constant in strength across it's whole radius */
  56988. Constant = 0,
  56989. /** Defines that impulse gets weaker if it's further from the origin */
  56990. Linear = 1
  56991. }
  56992. /**
  56993. * The strength of the force in correspondence to the distance of the affected object
  56994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56995. */
  56996. export enum PhysicsUpdraftMode {
  56997. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56998. Center = 0,
  56999. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57000. Perpendicular = 1
  57001. }
  57002. /**
  57003. * Interface for a physics hit data
  57004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57005. */
  57006. export interface PhysicsHitData {
  57007. /**
  57008. * The force applied at the contact point
  57009. */
  57010. force: Vector3;
  57011. /**
  57012. * The contact point
  57013. */
  57014. contactPoint: Vector3;
  57015. /**
  57016. * The distance from the origin to the contact point
  57017. */
  57018. distanceFromOrigin: number;
  57019. }
  57020. /**
  57021. * Interface for radial explosion event data
  57022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57023. */
  57024. export interface PhysicsRadialExplosionEventData {
  57025. /**
  57026. * A sphere used for the radial explosion event
  57027. */
  57028. sphere: Mesh;
  57029. }
  57030. /**
  57031. * Interface for gravitational field event data
  57032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57033. */
  57034. export interface PhysicsGravitationalFieldEventData {
  57035. /**
  57036. * A sphere mesh used for the gravitational field event
  57037. */
  57038. sphere: Mesh;
  57039. }
  57040. /**
  57041. * Interface for updraft event data
  57042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57043. */
  57044. export interface PhysicsUpdraftEventData {
  57045. /**
  57046. * A cylinder used for the updraft event
  57047. */
  57048. cylinder: Mesh;
  57049. }
  57050. /**
  57051. * Interface for vortex event data
  57052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57053. */
  57054. export interface PhysicsVortexEventData {
  57055. /**
  57056. * A cylinder used for the vortex event
  57057. */
  57058. cylinder: Mesh;
  57059. }
  57060. /**
  57061. * Interface for an affected physics impostor
  57062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57063. */
  57064. export interface PhysicsAffectedImpostorWithData {
  57065. /**
  57066. * The impostor affected by the effect
  57067. */
  57068. impostor: PhysicsImpostor;
  57069. /**
  57070. * The data about the hit/horce from the explosion
  57071. */
  57072. hitData: PhysicsHitData;
  57073. }
  57074. }
  57075. declare module BABYLON {
  57076. /** @hidden */
  57077. export var blackAndWhitePixelShader: {
  57078. name: string;
  57079. shader: string;
  57080. };
  57081. }
  57082. declare module BABYLON {
  57083. /**
  57084. * Post process used to render in black and white
  57085. */
  57086. export class BlackAndWhitePostProcess extends PostProcess {
  57087. /**
  57088. * Linear about to convert he result to black and white (default: 1)
  57089. */
  57090. degree: number;
  57091. /**
  57092. * Creates a black and white post process
  57093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57094. * @param name The name of the effect.
  57095. * @param options The required width/height ratio to downsize to before computing the render pass.
  57096. * @param camera The camera to apply the render pass to.
  57097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57098. * @param engine The engine which the post process will be applied. (default: current engine)
  57099. * @param reusable If the post process can be reused on the same frame. (default: false)
  57100. */
  57101. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57102. }
  57103. }
  57104. declare module BABYLON {
  57105. /**
  57106. * This represents a set of one or more post processes in Babylon.
  57107. * A post process can be used to apply a shader to a texture after it is rendered.
  57108. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57109. */
  57110. export class PostProcessRenderEffect {
  57111. private _postProcesses;
  57112. private _getPostProcesses;
  57113. private _singleInstance;
  57114. private _cameras;
  57115. private _indicesForCamera;
  57116. /**
  57117. * Name of the effect
  57118. * @hidden
  57119. */
  57120. _name: string;
  57121. /**
  57122. * Instantiates a post process render effect.
  57123. * A post process can be used to apply a shader to a texture after it is rendered.
  57124. * @param engine The engine the effect is tied to
  57125. * @param name The name of the effect
  57126. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57127. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57128. */
  57129. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57130. /**
  57131. * Checks if all the post processes in the effect are supported.
  57132. */
  57133. readonly isSupported: boolean;
  57134. /**
  57135. * Updates the current state of the effect
  57136. * @hidden
  57137. */
  57138. _update(): void;
  57139. /**
  57140. * Attaches the effect on cameras
  57141. * @param cameras The camera to attach to.
  57142. * @hidden
  57143. */
  57144. _attachCameras(cameras: Camera): void;
  57145. /**
  57146. * Attaches the effect on cameras
  57147. * @param cameras The camera to attach to.
  57148. * @hidden
  57149. */
  57150. _attachCameras(cameras: Camera[]): void;
  57151. /**
  57152. * Detaches the effect on cameras
  57153. * @param cameras The camera to detatch from.
  57154. * @hidden
  57155. */
  57156. _detachCameras(cameras: Camera): void;
  57157. /**
  57158. * Detatches the effect on cameras
  57159. * @param cameras The camera to detatch from.
  57160. * @hidden
  57161. */
  57162. _detachCameras(cameras: Camera[]): void;
  57163. /**
  57164. * Enables the effect on given cameras
  57165. * @param cameras The camera to enable.
  57166. * @hidden
  57167. */
  57168. _enable(cameras: Camera): void;
  57169. /**
  57170. * Enables the effect on given cameras
  57171. * @param cameras The camera to enable.
  57172. * @hidden
  57173. */
  57174. _enable(cameras: Nullable<Camera[]>): void;
  57175. /**
  57176. * Disables the effect on the given cameras
  57177. * @param cameras The camera to disable.
  57178. * @hidden
  57179. */
  57180. _disable(cameras: Camera): void;
  57181. /**
  57182. * Disables the effect on the given cameras
  57183. * @param cameras The camera to disable.
  57184. * @hidden
  57185. */
  57186. _disable(cameras: Nullable<Camera[]>): void;
  57187. /**
  57188. * Gets a list of the post processes contained in the effect.
  57189. * @param camera The camera to get the post processes on.
  57190. * @returns The list of the post processes in the effect.
  57191. */
  57192. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57193. }
  57194. }
  57195. declare module BABYLON {
  57196. /** @hidden */
  57197. export var extractHighlightsPixelShader: {
  57198. name: string;
  57199. shader: string;
  57200. };
  57201. }
  57202. declare module BABYLON {
  57203. /**
  57204. * 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.
  57205. */
  57206. export class ExtractHighlightsPostProcess extends PostProcess {
  57207. /**
  57208. * The luminance threshold, pixels below this value will be set to black.
  57209. */
  57210. threshold: number;
  57211. /** @hidden */
  57212. _exposure: number;
  57213. /**
  57214. * Post process which has the input texture to be used when performing highlight extraction
  57215. * @hidden
  57216. */
  57217. _inputPostProcess: Nullable<PostProcess>;
  57218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57219. }
  57220. }
  57221. declare module BABYLON {
  57222. /** @hidden */
  57223. export var bloomMergePixelShader: {
  57224. name: string;
  57225. shader: string;
  57226. };
  57227. }
  57228. declare module BABYLON {
  57229. /**
  57230. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57231. */
  57232. export class BloomMergePostProcess extends PostProcess {
  57233. /** Weight of the bloom to be added to the original input. */
  57234. weight: number;
  57235. /**
  57236. * Creates a new instance of @see BloomMergePostProcess
  57237. * @param name The name of the effect.
  57238. * @param originalFromInput Post process which's input will be used for the merge.
  57239. * @param blurred Blurred highlights post process which's output will be used.
  57240. * @param weight Weight of the bloom to be added to the original input.
  57241. * @param options The required width/height ratio to downsize to before computing the render pass.
  57242. * @param camera The camera to apply the render pass to.
  57243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57244. * @param engine The engine which the post process will be applied. (default: current engine)
  57245. * @param reusable If the post process can be reused on the same frame. (default: false)
  57246. * @param textureType Type of textures used when performing the post process. (default: 0)
  57247. * @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)
  57248. */
  57249. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57250. /** Weight of the bloom to be added to the original input. */
  57251. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57252. }
  57253. }
  57254. declare module BABYLON {
  57255. /**
  57256. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57257. */
  57258. export class BloomEffect extends PostProcessRenderEffect {
  57259. private bloomScale;
  57260. /**
  57261. * @hidden Internal
  57262. */
  57263. _effects: Array<PostProcess>;
  57264. /**
  57265. * @hidden Internal
  57266. */
  57267. _downscale: ExtractHighlightsPostProcess;
  57268. private _blurX;
  57269. private _blurY;
  57270. private _merge;
  57271. /**
  57272. * The luminance threshold to find bright areas of the image to bloom.
  57273. */
  57274. threshold: number;
  57275. /**
  57276. * The strength of the bloom.
  57277. */
  57278. weight: number;
  57279. /**
  57280. * Specifies the size of the bloom blur kernel, relative to the final output size
  57281. */
  57282. kernel: number;
  57283. /**
  57284. * Creates a new instance of @see BloomEffect
  57285. * @param scene The scene the effect belongs to.
  57286. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57287. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57288. * @param bloomWeight The the strength of bloom.
  57289. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57290. * @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)
  57291. */
  57292. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57293. /**
  57294. * Disposes each of the internal effects for a given camera.
  57295. * @param camera The camera to dispose the effect on.
  57296. */
  57297. disposeEffects(camera: Camera): void;
  57298. /**
  57299. * @hidden Internal
  57300. */
  57301. _updateEffects(): void;
  57302. /**
  57303. * Internal
  57304. * @returns if all the contained post processes are ready.
  57305. * @hidden
  57306. */
  57307. _isReady(): boolean;
  57308. }
  57309. }
  57310. declare module BABYLON {
  57311. /** @hidden */
  57312. export var chromaticAberrationPixelShader: {
  57313. name: string;
  57314. shader: string;
  57315. };
  57316. }
  57317. declare module BABYLON {
  57318. /**
  57319. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57320. */
  57321. export class ChromaticAberrationPostProcess extends PostProcess {
  57322. /**
  57323. * The amount of seperation of rgb channels (default: 30)
  57324. */
  57325. aberrationAmount: number;
  57326. /**
  57327. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57328. */
  57329. radialIntensity: number;
  57330. /**
  57331. * 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))
  57332. */
  57333. direction: Vector2;
  57334. /**
  57335. * 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))
  57336. */
  57337. centerPosition: Vector2;
  57338. /**
  57339. * Creates a new instance ChromaticAberrationPostProcess
  57340. * @param name The name of the effect.
  57341. * @param screenWidth The width of the screen to apply the effect on.
  57342. * @param screenHeight The height of the screen to apply the effect on.
  57343. * @param options The required width/height ratio to downsize to before computing the render pass.
  57344. * @param camera The camera to apply the render pass to.
  57345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57346. * @param engine The engine which the post process will be applied. (default: current engine)
  57347. * @param reusable If the post process can be reused on the same frame. (default: false)
  57348. * @param textureType Type of textures used when performing the post process. (default: 0)
  57349. * @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)
  57350. */
  57351. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57352. }
  57353. }
  57354. declare module BABYLON {
  57355. /** @hidden */
  57356. export var circleOfConfusionPixelShader: {
  57357. name: string;
  57358. shader: string;
  57359. };
  57360. }
  57361. declare module BABYLON {
  57362. /**
  57363. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57364. */
  57365. export class CircleOfConfusionPostProcess extends PostProcess {
  57366. /**
  57367. * 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.
  57368. */
  57369. lensSize: number;
  57370. /**
  57371. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57372. */
  57373. fStop: number;
  57374. /**
  57375. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57376. */
  57377. focusDistance: number;
  57378. /**
  57379. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57380. */
  57381. focalLength: number;
  57382. private _depthTexture;
  57383. /**
  57384. * Creates a new instance CircleOfConfusionPostProcess
  57385. * @param name The name of the effect.
  57386. * @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.
  57387. * @param options The required width/height ratio to downsize to before computing the render pass.
  57388. * @param camera The camera to apply the render pass to.
  57389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57390. * @param engine The engine which the post process will be applied. (default: current engine)
  57391. * @param reusable If the post process can be reused on the same frame. (default: false)
  57392. * @param textureType Type of textures used when performing the post process. (default: 0)
  57393. * @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)
  57394. */
  57395. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57396. /**
  57397. * 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.
  57398. */
  57399. depthTexture: RenderTargetTexture;
  57400. }
  57401. }
  57402. declare module BABYLON {
  57403. /** @hidden */
  57404. export var colorCorrectionPixelShader: {
  57405. name: string;
  57406. shader: string;
  57407. };
  57408. }
  57409. declare module BABYLON {
  57410. /**
  57411. *
  57412. * This post-process allows the modification of rendered colors by using
  57413. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57414. *
  57415. * The object needs to be provided an url to a texture containing the color
  57416. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57417. * Use an image editing software to tweak the LUT to match your needs.
  57418. *
  57419. * For an example of a color LUT, see here:
  57420. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57421. * For explanations on color grading, see here:
  57422. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57423. *
  57424. */
  57425. export class ColorCorrectionPostProcess extends PostProcess {
  57426. private _colorTableTexture;
  57427. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57428. }
  57429. }
  57430. declare module BABYLON {
  57431. /** @hidden */
  57432. export var convolutionPixelShader: {
  57433. name: string;
  57434. shader: string;
  57435. };
  57436. }
  57437. declare module BABYLON {
  57438. /**
  57439. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57440. * input texture to perform effects such as edge detection or sharpening
  57441. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57442. */
  57443. export class ConvolutionPostProcess extends PostProcess {
  57444. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57445. kernel: number[];
  57446. /**
  57447. * Creates a new instance ConvolutionPostProcess
  57448. * @param name The name of the effect.
  57449. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57450. * @param options The required width/height ratio to downsize to before computing the render pass.
  57451. * @param camera The camera to apply the render pass to.
  57452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57453. * @param engine The engine which the post process will be applied. (default: current engine)
  57454. * @param reusable If the post process can be reused on the same frame. (default: false)
  57455. * @param textureType Type of textures used when performing the post process. (default: 0)
  57456. */
  57457. constructor(name: string,
  57458. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57459. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57460. /**
  57461. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57462. */
  57463. static EdgeDetect0Kernel: number[];
  57464. /**
  57465. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57466. */
  57467. static EdgeDetect1Kernel: number[];
  57468. /**
  57469. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57470. */
  57471. static EdgeDetect2Kernel: number[];
  57472. /**
  57473. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57474. */
  57475. static SharpenKernel: number[];
  57476. /**
  57477. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57478. */
  57479. static EmbossKernel: number[];
  57480. /**
  57481. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57482. */
  57483. static GaussianKernel: number[];
  57484. }
  57485. }
  57486. declare module BABYLON {
  57487. /**
  57488. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57489. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57490. * based on samples that have a large difference in distance than the center pixel.
  57491. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57492. */
  57493. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57494. direction: Vector2;
  57495. /**
  57496. * Creates a new instance CircleOfConfusionPostProcess
  57497. * @param name The name of the effect.
  57498. * @param scene The scene the effect belongs to.
  57499. * @param direction The direction the blur should be applied.
  57500. * @param kernel The size of the kernel used to blur.
  57501. * @param options The required width/height ratio to downsize to before computing the render pass.
  57502. * @param camera The camera to apply the render pass to.
  57503. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57504. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57506. * @param engine The engine which the post process will be applied. (default: current engine)
  57507. * @param reusable If the post process can be reused on the same frame. (default: false)
  57508. * @param textureType Type of textures used when performing the post process. (default: 0)
  57509. * @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)
  57510. */
  57511. 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);
  57512. }
  57513. }
  57514. declare module BABYLON {
  57515. /** @hidden */
  57516. export var depthOfFieldMergePixelShader: {
  57517. name: string;
  57518. shader: string;
  57519. };
  57520. }
  57521. declare module BABYLON {
  57522. /**
  57523. * Options to be set when merging outputs from the default pipeline.
  57524. */
  57525. export class DepthOfFieldMergePostProcessOptions {
  57526. /**
  57527. * The original image to merge on top of
  57528. */
  57529. originalFromInput: PostProcess;
  57530. /**
  57531. * Parameters to perform the merge of the depth of field effect
  57532. */
  57533. depthOfField?: {
  57534. circleOfConfusion: PostProcess;
  57535. blurSteps: Array<PostProcess>;
  57536. };
  57537. /**
  57538. * Parameters to perform the merge of bloom effect
  57539. */
  57540. bloom?: {
  57541. blurred: PostProcess;
  57542. weight: number;
  57543. };
  57544. }
  57545. /**
  57546. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57547. */
  57548. export class DepthOfFieldMergePostProcess extends PostProcess {
  57549. private blurSteps;
  57550. /**
  57551. * Creates a new instance of DepthOfFieldMergePostProcess
  57552. * @param name The name of the effect.
  57553. * @param originalFromInput Post process which's input will be used for the merge.
  57554. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57555. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57556. * @param options The required width/height ratio to downsize to before computing the render pass.
  57557. * @param camera The camera to apply the render pass to.
  57558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57559. * @param engine The engine which the post process will be applied. (default: current engine)
  57560. * @param reusable If the post process can be reused on the same frame. (default: false)
  57561. * @param textureType Type of textures used when performing the post process. (default: 0)
  57562. * @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)
  57563. */
  57564. 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);
  57565. /**
  57566. * Updates the effect with the current post process compile time values and recompiles the shader.
  57567. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57568. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57569. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57570. * @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
  57571. * @param onCompiled Called when the shader has been compiled.
  57572. * @param onError Called if there is an error when compiling a shader.
  57573. */
  57574. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57575. }
  57576. }
  57577. declare module BABYLON {
  57578. /**
  57579. * Specifies the level of max blur that should be applied when using the depth of field effect
  57580. */
  57581. export enum DepthOfFieldEffectBlurLevel {
  57582. /**
  57583. * Subtle blur
  57584. */
  57585. Low = 0,
  57586. /**
  57587. * Medium blur
  57588. */
  57589. Medium = 1,
  57590. /**
  57591. * Large blur
  57592. */
  57593. High = 2
  57594. }
  57595. /**
  57596. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57597. */
  57598. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57599. private _circleOfConfusion;
  57600. /**
  57601. * @hidden Internal, blurs from high to low
  57602. */
  57603. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57604. private _depthOfFieldBlurY;
  57605. private _dofMerge;
  57606. /**
  57607. * @hidden Internal post processes in depth of field effect
  57608. */
  57609. _effects: Array<PostProcess>;
  57610. /**
  57611. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57612. */
  57613. focalLength: number;
  57614. /**
  57615. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57616. */
  57617. fStop: number;
  57618. /**
  57619. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57620. */
  57621. focusDistance: number;
  57622. /**
  57623. * 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.
  57624. */
  57625. lensSize: number;
  57626. /**
  57627. * Creates a new instance DepthOfFieldEffect
  57628. * @param scene The scene the effect belongs to.
  57629. * @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.
  57630. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57631. * @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)
  57632. */
  57633. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57634. /**
  57635. * Get the current class name of the current effet
  57636. * @returns "DepthOfFieldEffect"
  57637. */
  57638. getClassName(): string;
  57639. /**
  57640. * 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.
  57641. */
  57642. depthTexture: RenderTargetTexture;
  57643. /**
  57644. * Disposes each of the internal effects for a given camera.
  57645. * @param camera The camera to dispose the effect on.
  57646. */
  57647. disposeEffects(camera: Camera): void;
  57648. /**
  57649. * @hidden Internal
  57650. */
  57651. _updateEffects(): void;
  57652. /**
  57653. * Internal
  57654. * @returns if all the contained post processes are ready.
  57655. * @hidden
  57656. */
  57657. _isReady(): boolean;
  57658. }
  57659. }
  57660. declare module BABYLON {
  57661. /** @hidden */
  57662. export var displayPassPixelShader: {
  57663. name: string;
  57664. shader: string;
  57665. };
  57666. }
  57667. declare module BABYLON {
  57668. /**
  57669. * DisplayPassPostProcess which produces an output the same as it's input
  57670. */
  57671. export class DisplayPassPostProcess extends PostProcess {
  57672. /**
  57673. * Creates the DisplayPassPostProcess
  57674. * @param name The name of the effect.
  57675. * @param options The required width/height ratio to downsize to before computing the render pass.
  57676. * @param camera The camera to apply the render pass to.
  57677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57678. * @param engine The engine which the post process will be applied. (default: current engine)
  57679. * @param reusable If the post process can be reused on the same frame. (default: false)
  57680. */
  57681. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57682. }
  57683. }
  57684. declare module BABYLON {
  57685. /** @hidden */
  57686. export var filterPixelShader: {
  57687. name: string;
  57688. shader: string;
  57689. };
  57690. }
  57691. declare module BABYLON {
  57692. /**
  57693. * Applies a kernel filter to the image
  57694. */
  57695. export class FilterPostProcess extends PostProcess {
  57696. /** The matrix to be applied to the image */
  57697. kernelMatrix: Matrix;
  57698. /**
  57699. *
  57700. * @param name The name of the effect.
  57701. * @param kernelMatrix The matrix to be applied to the image
  57702. * @param options The required width/height ratio to downsize to before computing the render pass.
  57703. * @param camera The camera to apply the render pass to.
  57704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57705. * @param engine The engine which the post process will be applied. (default: current engine)
  57706. * @param reusable If the post process can be reused on the same frame. (default: false)
  57707. */
  57708. constructor(name: string,
  57709. /** The matrix to be applied to the image */
  57710. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57711. }
  57712. }
  57713. declare module BABYLON {
  57714. /** @hidden */
  57715. export var fxaaPixelShader: {
  57716. name: string;
  57717. shader: string;
  57718. };
  57719. }
  57720. declare module BABYLON {
  57721. /** @hidden */
  57722. export var fxaaVertexShader: {
  57723. name: string;
  57724. shader: string;
  57725. };
  57726. }
  57727. declare module BABYLON {
  57728. /**
  57729. * Fxaa post process
  57730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57731. */
  57732. export class FxaaPostProcess extends PostProcess {
  57733. /** @hidden */
  57734. texelWidth: number;
  57735. /** @hidden */
  57736. texelHeight: number;
  57737. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57738. private _getDefines;
  57739. }
  57740. }
  57741. declare module BABYLON {
  57742. /** @hidden */
  57743. export var grainPixelShader: {
  57744. name: string;
  57745. shader: string;
  57746. };
  57747. }
  57748. declare module BABYLON {
  57749. /**
  57750. * The GrainPostProcess adds noise to the image at mid luminance levels
  57751. */
  57752. export class GrainPostProcess extends PostProcess {
  57753. /**
  57754. * The intensity of the grain added (default: 30)
  57755. */
  57756. intensity: number;
  57757. /**
  57758. * If the grain should be randomized on every frame
  57759. */
  57760. animated: boolean;
  57761. /**
  57762. * Creates a new instance of @see GrainPostProcess
  57763. * @param name The name of the effect.
  57764. * @param options The required width/height ratio to downsize to before computing the render pass.
  57765. * @param camera The camera to apply the render pass to.
  57766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57767. * @param engine The engine which the post process will be applied. (default: current engine)
  57768. * @param reusable If the post process can be reused on the same frame. (default: false)
  57769. * @param textureType Type of textures used when performing the post process. (default: 0)
  57770. * @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)
  57771. */
  57772. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57773. }
  57774. }
  57775. declare module BABYLON {
  57776. /** @hidden */
  57777. export var highlightsPixelShader: {
  57778. name: string;
  57779. shader: string;
  57780. };
  57781. }
  57782. declare module BABYLON {
  57783. /**
  57784. * Extracts highlights from the image
  57785. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57786. */
  57787. export class HighlightsPostProcess extends PostProcess {
  57788. /**
  57789. * Extracts highlights from the image
  57790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57791. * @param name The name of the effect.
  57792. * @param options The required width/height ratio to downsize to before computing the render pass.
  57793. * @param camera The camera to apply the render pass to.
  57794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57795. * @param engine The engine which the post process will be applied. (default: current engine)
  57796. * @param reusable If the post process can be reused on the same frame. (default: false)
  57797. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57798. */
  57799. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57800. }
  57801. }
  57802. declare module BABYLON {
  57803. /** @hidden */
  57804. export var mrtFragmentDeclaration: {
  57805. name: string;
  57806. shader: string;
  57807. };
  57808. }
  57809. declare module BABYLON {
  57810. /** @hidden */
  57811. export var geometryPixelShader: {
  57812. name: string;
  57813. shader: string;
  57814. };
  57815. }
  57816. declare module BABYLON {
  57817. /** @hidden */
  57818. export var geometryVertexShader: {
  57819. name: string;
  57820. shader: string;
  57821. };
  57822. }
  57823. declare module BABYLON {
  57824. /** @hidden */
  57825. interface ISavedTransformationMatrix {
  57826. world: Matrix;
  57827. viewProjection: Matrix;
  57828. }
  57829. /**
  57830. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57831. */
  57832. export class GeometryBufferRenderer {
  57833. /**
  57834. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57835. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57836. */
  57837. static readonly POSITION_TEXTURE_TYPE: number;
  57838. /**
  57839. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57840. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57841. */
  57842. static readonly VELOCITY_TEXTURE_TYPE: number;
  57843. /**
  57844. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57845. * in order to compute objects velocities when enableVelocity is set to "true"
  57846. * @hidden
  57847. */
  57848. _previousTransformationMatrices: {
  57849. [index: number]: ISavedTransformationMatrix;
  57850. };
  57851. /**
  57852. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57853. * in order to compute objects velocities when enableVelocity is set to "true"
  57854. * @hidden
  57855. */
  57856. _previousBonesTransformationMatrices: {
  57857. [index: number]: Float32Array;
  57858. };
  57859. /**
  57860. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57861. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57862. */
  57863. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57864. private _scene;
  57865. private _multiRenderTarget;
  57866. private _ratio;
  57867. private _enablePosition;
  57868. private _enableVelocity;
  57869. private _positionIndex;
  57870. private _velocityIndex;
  57871. protected _effect: Effect;
  57872. protected _cachedDefines: string;
  57873. /**
  57874. * Set the render list (meshes to be rendered) used in the G buffer.
  57875. */
  57876. renderList: Mesh[];
  57877. /**
  57878. * Gets wether or not G buffer are supported by the running hardware.
  57879. * This requires draw buffer supports
  57880. */
  57881. readonly isSupported: boolean;
  57882. /**
  57883. * Returns the index of the given texture type in the G-Buffer textures array
  57884. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57885. * @returns the index of the given texture type in the G-Buffer textures array
  57886. */
  57887. getTextureIndex(textureType: number): number;
  57888. /**
  57889. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57890. */
  57891. /**
  57892. * Sets whether or not objects positions are enabled for the G buffer.
  57893. */
  57894. enablePosition: boolean;
  57895. /**
  57896. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57897. */
  57898. /**
  57899. * Sets wether or not objects velocities are enabled for the G buffer.
  57900. */
  57901. enableVelocity: boolean;
  57902. /**
  57903. * Gets the scene associated with the buffer.
  57904. */
  57905. readonly scene: Scene;
  57906. /**
  57907. * Gets the ratio used by the buffer during its creation.
  57908. * How big is the buffer related to the main canvas.
  57909. */
  57910. readonly ratio: number;
  57911. /** @hidden */
  57912. static _SceneComponentInitialization: (scene: Scene) => void;
  57913. /**
  57914. * Creates a new G Buffer for the scene
  57915. * @param scene The scene the buffer belongs to
  57916. * @param ratio How big is the buffer related to the main canvas.
  57917. */
  57918. constructor(scene: Scene, ratio?: number);
  57919. /**
  57920. * Checks wether everything is ready to render a submesh to the G buffer.
  57921. * @param subMesh the submesh to check readiness for
  57922. * @param useInstances is the mesh drawn using instance or not
  57923. * @returns true if ready otherwise false
  57924. */
  57925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57926. /**
  57927. * Gets the current underlying G Buffer.
  57928. * @returns the buffer
  57929. */
  57930. getGBuffer(): MultiRenderTarget;
  57931. /**
  57932. * Gets the number of samples used to render the buffer (anti aliasing).
  57933. */
  57934. /**
  57935. * Sets the number of samples used to render the buffer (anti aliasing).
  57936. */
  57937. samples: number;
  57938. /**
  57939. * Disposes the renderer and frees up associated resources.
  57940. */
  57941. dispose(): void;
  57942. protected _createRenderTargets(): void;
  57943. private _copyBonesTransformationMatrices;
  57944. }
  57945. }
  57946. declare module BABYLON {
  57947. interface Scene {
  57948. /** @hidden (Backing field) */
  57949. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57950. /**
  57951. * Gets or Sets the current geometry buffer associated to the scene.
  57952. */
  57953. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57954. /**
  57955. * Enables a GeometryBufferRender and associates it with the scene
  57956. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57957. * @returns the GeometryBufferRenderer
  57958. */
  57959. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57960. /**
  57961. * Disables the GeometryBufferRender associated with the scene
  57962. */
  57963. disableGeometryBufferRenderer(): void;
  57964. }
  57965. /**
  57966. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57967. * in several rendering techniques.
  57968. */
  57969. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57970. /**
  57971. * The component name helpful to identify the component in the list of scene components.
  57972. */
  57973. readonly name: string;
  57974. /**
  57975. * The scene the component belongs to.
  57976. */
  57977. scene: Scene;
  57978. /**
  57979. * Creates a new instance of the component for the given scene
  57980. * @param scene Defines the scene to register the component in
  57981. */
  57982. constructor(scene: Scene);
  57983. /**
  57984. * Registers the component in a given scene
  57985. */
  57986. register(): void;
  57987. /**
  57988. * Rebuilds the elements related to this component in case of
  57989. * context lost for instance.
  57990. */
  57991. rebuild(): void;
  57992. /**
  57993. * Disposes the component and the associated ressources
  57994. */
  57995. dispose(): void;
  57996. private _gatherRenderTargets;
  57997. }
  57998. }
  57999. declare module BABYLON {
  58000. /** @hidden */
  58001. export var motionBlurPixelShader: {
  58002. name: string;
  58003. shader: string;
  58004. };
  58005. }
  58006. declare module BABYLON {
  58007. /**
  58008. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58009. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58010. * As an example, all you have to do is to create the post-process:
  58011. * var mb = new BABYLON.MotionBlurPostProcess(
  58012. * 'mb', // The name of the effect.
  58013. * scene, // The scene containing the objects to blur according to their velocity.
  58014. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58015. * camera // The camera to apply the render pass to.
  58016. * );
  58017. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58018. */
  58019. export class MotionBlurPostProcess extends PostProcess {
  58020. /**
  58021. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58022. */
  58023. motionStrength: number;
  58024. /**
  58025. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58026. */
  58027. /**
  58028. * Sets the number of iterations to be used for motion blur quality
  58029. */
  58030. motionBlurSamples: number;
  58031. private _motionBlurSamples;
  58032. private _geometryBufferRenderer;
  58033. /**
  58034. * Creates a new instance MotionBlurPostProcess
  58035. * @param name The name of the effect.
  58036. * @param scene The scene containing the objects to blur according to their velocity.
  58037. * @param options The required width/height ratio to downsize to before computing the render pass.
  58038. * @param camera The camera to apply the render pass to.
  58039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58040. * @param engine The engine which the post process will be applied. (default: current engine)
  58041. * @param reusable If the post process can be reused on the same frame. (default: false)
  58042. * @param textureType Type of textures used when performing the post process. (default: 0)
  58043. * @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)
  58044. */
  58045. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58046. /**
  58047. * Excludes the given skinned mesh from computing bones velocities.
  58048. * 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.
  58049. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58050. */
  58051. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58052. /**
  58053. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58054. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58055. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58056. */
  58057. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58058. /**
  58059. * Disposes the post process.
  58060. * @param camera The camera to dispose the post process on.
  58061. */
  58062. dispose(camera?: Camera): void;
  58063. }
  58064. }
  58065. declare module BABYLON {
  58066. /** @hidden */
  58067. export var refractionPixelShader: {
  58068. name: string;
  58069. shader: string;
  58070. };
  58071. }
  58072. declare module BABYLON {
  58073. /**
  58074. * Post process which applies a refractin texture
  58075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58076. */
  58077. export class RefractionPostProcess extends PostProcess {
  58078. /** the base color of the refraction (used to taint the rendering) */
  58079. color: Color3;
  58080. /** simulated refraction depth */
  58081. depth: number;
  58082. /** the coefficient of the base color (0 to remove base color tainting) */
  58083. colorLevel: number;
  58084. private _refTexture;
  58085. private _ownRefractionTexture;
  58086. /**
  58087. * Gets or sets the refraction texture
  58088. * Please note that you are responsible for disposing the texture if you set it manually
  58089. */
  58090. refractionTexture: Texture;
  58091. /**
  58092. * Initializes the RefractionPostProcess
  58093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58094. * @param name The name of the effect.
  58095. * @param refractionTextureUrl Url of the refraction texture to use
  58096. * @param color the base color of the refraction (used to taint the rendering)
  58097. * @param depth simulated refraction depth
  58098. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58099. * @param camera The camera to apply the render pass to.
  58100. * @param options The required width/height ratio to downsize to before computing the render pass.
  58101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58102. * @param engine The engine which the post process will be applied. (default: current engine)
  58103. * @param reusable If the post process can be reused on the same frame. (default: false)
  58104. */
  58105. constructor(name: string, refractionTextureUrl: string,
  58106. /** the base color of the refraction (used to taint the rendering) */
  58107. color: Color3,
  58108. /** simulated refraction depth */
  58109. depth: number,
  58110. /** the coefficient of the base color (0 to remove base color tainting) */
  58111. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58112. /**
  58113. * Disposes of the post process
  58114. * @param camera Camera to dispose post process on
  58115. */
  58116. dispose(camera: Camera): void;
  58117. }
  58118. }
  58119. declare module BABYLON {
  58120. /** @hidden */
  58121. export var sharpenPixelShader: {
  58122. name: string;
  58123. shader: string;
  58124. };
  58125. }
  58126. declare module BABYLON {
  58127. /**
  58128. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58129. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58130. */
  58131. export class SharpenPostProcess extends PostProcess {
  58132. /**
  58133. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58134. */
  58135. colorAmount: number;
  58136. /**
  58137. * How much sharpness should be applied (default: 0.3)
  58138. */
  58139. edgeAmount: number;
  58140. /**
  58141. * Creates a new instance ConvolutionPostProcess
  58142. * @param name The name of the effect.
  58143. * @param options The required width/height ratio to downsize to before computing the render pass.
  58144. * @param camera The camera to apply the render pass to.
  58145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58146. * @param engine The engine which the post process will be applied. (default: current engine)
  58147. * @param reusable If the post process can be reused on the same frame. (default: false)
  58148. * @param textureType Type of textures used when performing the post process. (default: 0)
  58149. * @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)
  58150. */
  58151. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58152. }
  58153. }
  58154. declare module BABYLON {
  58155. /**
  58156. * PostProcessRenderPipeline
  58157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58158. */
  58159. export class PostProcessRenderPipeline {
  58160. private engine;
  58161. private _renderEffects;
  58162. private _renderEffectsForIsolatedPass;
  58163. /**
  58164. * List of inspectable custom properties (used by the Inspector)
  58165. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58166. */
  58167. inspectableCustomProperties: IInspectable[];
  58168. /**
  58169. * @hidden
  58170. */
  58171. protected _cameras: Camera[];
  58172. /** @hidden */
  58173. _name: string;
  58174. /**
  58175. * Gets pipeline name
  58176. */
  58177. readonly name: string;
  58178. /**
  58179. * Initializes a PostProcessRenderPipeline
  58180. * @param engine engine to add the pipeline to
  58181. * @param name name of the pipeline
  58182. */
  58183. constructor(engine: Engine, name: string);
  58184. /**
  58185. * Gets the class name
  58186. * @returns "PostProcessRenderPipeline"
  58187. */
  58188. getClassName(): string;
  58189. /**
  58190. * If all the render effects in the pipeline are supported
  58191. */
  58192. readonly isSupported: boolean;
  58193. /**
  58194. * Adds an effect to the pipeline
  58195. * @param renderEffect the effect to add
  58196. */
  58197. addEffect(renderEffect: PostProcessRenderEffect): void;
  58198. /** @hidden */
  58199. _rebuild(): void;
  58200. /** @hidden */
  58201. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58202. /** @hidden */
  58203. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58204. /** @hidden */
  58205. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58206. /** @hidden */
  58207. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58208. /** @hidden */
  58209. _attachCameras(cameras: Camera, unique: boolean): void;
  58210. /** @hidden */
  58211. _attachCameras(cameras: Camera[], unique: boolean): void;
  58212. /** @hidden */
  58213. _detachCameras(cameras: Camera): void;
  58214. /** @hidden */
  58215. _detachCameras(cameras: Nullable<Camera[]>): void;
  58216. /** @hidden */
  58217. _update(): void;
  58218. /** @hidden */
  58219. _reset(): void;
  58220. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58221. /**
  58222. * Disposes of the pipeline
  58223. */
  58224. dispose(): void;
  58225. }
  58226. }
  58227. declare module BABYLON {
  58228. /**
  58229. * PostProcessRenderPipelineManager class
  58230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58231. */
  58232. export class PostProcessRenderPipelineManager {
  58233. private _renderPipelines;
  58234. /**
  58235. * Initializes a PostProcessRenderPipelineManager
  58236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58237. */
  58238. constructor();
  58239. /**
  58240. * Gets the list of supported render pipelines
  58241. */
  58242. readonly supportedPipelines: PostProcessRenderPipeline[];
  58243. /**
  58244. * Adds a pipeline to the manager
  58245. * @param renderPipeline The pipeline to add
  58246. */
  58247. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58248. /**
  58249. * Attaches a camera to the pipeline
  58250. * @param renderPipelineName The name of the pipeline to attach to
  58251. * @param cameras the camera to attach
  58252. * @param unique if the camera can be attached multiple times to the pipeline
  58253. */
  58254. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58255. /**
  58256. * Detaches a camera from the pipeline
  58257. * @param renderPipelineName The name of the pipeline to detach from
  58258. * @param cameras the camera to detach
  58259. */
  58260. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58261. /**
  58262. * Enables an effect by name on a pipeline
  58263. * @param renderPipelineName the name of the pipeline to enable the effect in
  58264. * @param renderEffectName the name of the effect to enable
  58265. * @param cameras the cameras that the effect should be enabled on
  58266. */
  58267. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58268. /**
  58269. * Disables an effect by name on a pipeline
  58270. * @param renderPipelineName the name of the pipeline to disable the effect in
  58271. * @param renderEffectName the name of the effect to disable
  58272. * @param cameras the cameras that the effect should be disabled on
  58273. */
  58274. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58275. /**
  58276. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58277. */
  58278. update(): void;
  58279. /** @hidden */
  58280. _rebuild(): void;
  58281. /**
  58282. * Disposes of the manager and pipelines
  58283. */
  58284. dispose(): void;
  58285. }
  58286. }
  58287. declare module BABYLON {
  58288. interface Scene {
  58289. /** @hidden (Backing field) */
  58290. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58291. /**
  58292. * Gets the postprocess render pipeline manager
  58293. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58294. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58295. */
  58296. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58297. }
  58298. /**
  58299. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58300. */
  58301. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58302. /**
  58303. * The component name helpfull to identify the component in the list of scene components.
  58304. */
  58305. readonly name: string;
  58306. /**
  58307. * The scene the component belongs to.
  58308. */
  58309. scene: Scene;
  58310. /**
  58311. * Creates a new instance of the component for the given scene
  58312. * @param scene Defines the scene to register the component in
  58313. */
  58314. constructor(scene: Scene);
  58315. /**
  58316. * Registers the component in a given scene
  58317. */
  58318. register(): void;
  58319. /**
  58320. * Rebuilds the elements related to this component in case of
  58321. * context lost for instance.
  58322. */
  58323. rebuild(): void;
  58324. /**
  58325. * Disposes the component and the associated ressources
  58326. */
  58327. dispose(): void;
  58328. private _gatherRenderTargets;
  58329. }
  58330. }
  58331. declare module BABYLON {
  58332. /**
  58333. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58334. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58335. */
  58336. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58337. private _scene;
  58338. private _camerasToBeAttached;
  58339. /**
  58340. * ID of the sharpen post process,
  58341. */
  58342. private readonly SharpenPostProcessId;
  58343. /**
  58344. * @ignore
  58345. * ID of the image processing post process;
  58346. */
  58347. readonly ImageProcessingPostProcessId: string;
  58348. /**
  58349. * @ignore
  58350. * ID of the Fast Approximate Anti-Aliasing post process;
  58351. */
  58352. readonly FxaaPostProcessId: string;
  58353. /**
  58354. * ID of the chromatic aberration post process,
  58355. */
  58356. private readonly ChromaticAberrationPostProcessId;
  58357. /**
  58358. * ID of the grain post process
  58359. */
  58360. private readonly GrainPostProcessId;
  58361. /**
  58362. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58363. */
  58364. sharpen: SharpenPostProcess;
  58365. private _sharpenEffect;
  58366. private bloom;
  58367. /**
  58368. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58369. */
  58370. depthOfField: DepthOfFieldEffect;
  58371. /**
  58372. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58373. */
  58374. fxaa: FxaaPostProcess;
  58375. /**
  58376. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58377. */
  58378. imageProcessing: ImageProcessingPostProcess;
  58379. /**
  58380. * Chromatic aberration post process which will shift rgb colors in the image
  58381. */
  58382. chromaticAberration: ChromaticAberrationPostProcess;
  58383. private _chromaticAberrationEffect;
  58384. /**
  58385. * Grain post process which add noise to the image
  58386. */
  58387. grain: GrainPostProcess;
  58388. private _grainEffect;
  58389. /**
  58390. * Glow post process which adds a glow to emissive areas of the image
  58391. */
  58392. private _glowLayer;
  58393. /**
  58394. * Animations which can be used to tweak settings over a period of time
  58395. */
  58396. animations: Animation[];
  58397. private _imageProcessingConfigurationObserver;
  58398. private _sharpenEnabled;
  58399. private _bloomEnabled;
  58400. private _depthOfFieldEnabled;
  58401. private _depthOfFieldBlurLevel;
  58402. private _fxaaEnabled;
  58403. private _imageProcessingEnabled;
  58404. private _defaultPipelineTextureType;
  58405. private _bloomScale;
  58406. private _chromaticAberrationEnabled;
  58407. private _grainEnabled;
  58408. private _buildAllowed;
  58409. /**
  58410. * Gets active scene
  58411. */
  58412. readonly scene: Scene;
  58413. /**
  58414. * Enable or disable the sharpen process from the pipeline
  58415. */
  58416. sharpenEnabled: boolean;
  58417. private _resizeObserver;
  58418. private _hardwareScaleLevel;
  58419. private _bloomKernel;
  58420. /**
  58421. * Specifies the size of the bloom blur kernel, relative to the final output size
  58422. */
  58423. bloomKernel: number;
  58424. /**
  58425. * Specifies the weight of the bloom in the final rendering
  58426. */
  58427. private _bloomWeight;
  58428. /**
  58429. * Specifies the luma threshold for the area that will be blurred by the bloom
  58430. */
  58431. private _bloomThreshold;
  58432. private _hdr;
  58433. /**
  58434. * The strength of the bloom.
  58435. */
  58436. bloomWeight: number;
  58437. /**
  58438. * The strength of the bloom.
  58439. */
  58440. bloomThreshold: number;
  58441. /**
  58442. * The scale of the bloom, lower value will provide better performance.
  58443. */
  58444. bloomScale: number;
  58445. /**
  58446. * Enable or disable the bloom from the pipeline
  58447. */
  58448. bloomEnabled: boolean;
  58449. private _rebuildBloom;
  58450. /**
  58451. * If the depth of field is enabled.
  58452. */
  58453. depthOfFieldEnabled: boolean;
  58454. /**
  58455. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58456. */
  58457. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58458. /**
  58459. * If the anti aliasing is enabled.
  58460. */
  58461. fxaaEnabled: boolean;
  58462. private _samples;
  58463. /**
  58464. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58465. */
  58466. samples: number;
  58467. /**
  58468. * If image processing is enabled.
  58469. */
  58470. imageProcessingEnabled: boolean;
  58471. /**
  58472. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58473. */
  58474. glowLayerEnabled: boolean;
  58475. /**
  58476. * Gets the glow layer (or null if not defined)
  58477. */
  58478. readonly glowLayer: Nullable<GlowLayer>;
  58479. /**
  58480. * Enable or disable the chromaticAberration process from the pipeline
  58481. */
  58482. chromaticAberrationEnabled: boolean;
  58483. /**
  58484. * Enable or disable the grain process from the pipeline
  58485. */
  58486. grainEnabled: boolean;
  58487. /**
  58488. * @constructor
  58489. * @param name - The rendering pipeline name (default: "")
  58490. * @param hdr - If high dynamic range textures should be used (default: true)
  58491. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58492. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58493. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58494. */
  58495. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58496. /**
  58497. * Get the class name
  58498. * @returns "DefaultRenderingPipeline"
  58499. */
  58500. getClassName(): string;
  58501. /**
  58502. * Force the compilation of the entire pipeline.
  58503. */
  58504. prepare(): void;
  58505. private _hasCleared;
  58506. private _prevPostProcess;
  58507. private _prevPrevPostProcess;
  58508. private _setAutoClearAndTextureSharing;
  58509. private _depthOfFieldSceneObserver;
  58510. private _buildPipeline;
  58511. private _disposePostProcesses;
  58512. /**
  58513. * Adds a camera to the pipeline
  58514. * @param camera the camera to be added
  58515. */
  58516. addCamera(camera: Camera): void;
  58517. /**
  58518. * Removes a camera from the pipeline
  58519. * @param camera the camera to remove
  58520. */
  58521. removeCamera(camera: Camera): void;
  58522. /**
  58523. * Dispose of the pipeline and stop all post processes
  58524. */
  58525. dispose(): void;
  58526. /**
  58527. * Serialize the rendering pipeline (Used when exporting)
  58528. * @returns the serialized object
  58529. */
  58530. serialize(): any;
  58531. /**
  58532. * Parse the serialized pipeline
  58533. * @param source Source pipeline.
  58534. * @param scene The scene to load the pipeline to.
  58535. * @param rootUrl The URL of the serialized pipeline.
  58536. * @returns An instantiated pipeline from the serialized object.
  58537. */
  58538. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /** @hidden */
  58543. export var lensHighlightsPixelShader: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module BABYLON {
  58549. /** @hidden */
  58550. export var depthOfFieldPixelShader: {
  58551. name: string;
  58552. shader: string;
  58553. };
  58554. }
  58555. declare module BABYLON {
  58556. /**
  58557. * BABYLON.JS Chromatic Aberration GLSL Shader
  58558. * Author: Olivier Guyot
  58559. * Separates very slightly R, G and B colors on the edges of the screen
  58560. * Inspired by Francois Tarlier & Martins Upitis
  58561. */
  58562. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58563. /**
  58564. * @ignore
  58565. * The chromatic aberration PostProcess id in the pipeline
  58566. */
  58567. LensChromaticAberrationEffect: string;
  58568. /**
  58569. * @ignore
  58570. * The highlights enhancing PostProcess id in the pipeline
  58571. */
  58572. HighlightsEnhancingEffect: string;
  58573. /**
  58574. * @ignore
  58575. * The depth-of-field PostProcess id in the pipeline
  58576. */
  58577. LensDepthOfFieldEffect: string;
  58578. private _scene;
  58579. private _depthTexture;
  58580. private _grainTexture;
  58581. private _chromaticAberrationPostProcess;
  58582. private _highlightsPostProcess;
  58583. private _depthOfFieldPostProcess;
  58584. private _edgeBlur;
  58585. private _grainAmount;
  58586. private _chromaticAberration;
  58587. private _distortion;
  58588. private _highlightsGain;
  58589. private _highlightsThreshold;
  58590. private _dofDistance;
  58591. private _dofAperture;
  58592. private _dofDarken;
  58593. private _dofPentagon;
  58594. private _blurNoise;
  58595. /**
  58596. * @constructor
  58597. *
  58598. * Effect parameters are as follow:
  58599. * {
  58600. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58601. * edge_blur: number; // from 0 to x (1 for realism)
  58602. * distortion: number; // from 0 to x (1 for realism)
  58603. * grain_amount: number; // from 0 to 1
  58604. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58605. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58606. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58607. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58608. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58609. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58610. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58611. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58612. * }
  58613. * Note: if an effect parameter is unset, effect is disabled
  58614. *
  58615. * @param name The rendering pipeline name
  58616. * @param parameters - An object containing all parameters (see above)
  58617. * @param scene The scene linked to this pipeline
  58618. * @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)
  58619. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58620. */
  58621. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58622. /**
  58623. * Get the class name
  58624. * @returns "LensRenderingPipeline"
  58625. */
  58626. getClassName(): string;
  58627. /**
  58628. * Gets associated scene
  58629. */
  58630. readonly scene: Scene;
  58631. /**
  58632. * Gets or sets the edge blur
  58633. */
  58634. edgeBlur: number;
  58635. /**
  58636. * Gets or sets the grain amount
  58637. */
  58638. grainAmount: number;
  58639. /**
  58640. * Gets or sets the chromatic aberration amount
  58641. */
  58642. chromaticAberration: number;
  58643. /**
  58644. * Gets or sets the depth of field aperture
  58645. */
  58646. dofAperture: number;
  58647. /**
  58648. * Gets or sets the edge distortion
  58649. */
  58650. edgeDistortion: number;
  58651. /**
  58652. * Gets or sets the depth of field distortion
  58653. */
  58654. dofDistortion: number;
  58655. /**
  58656. * Gets or sets the darken out of focus amount
  58657. */
  58658. darkenOutOfFocus: number;
  58659. /**
  58660. * Gets or sets a boolean indicating if blur noise is enabled
  58661. */
  58662. blurNoise: boolean;
  58663. /**
  58664. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58665. */
  58666. pentagonBokeh: boolean;
  58667. /**
  58668. * Gets or sets the highlight grain amount
  58669. */
  58670. highlightsGain: number;
  58671. /**
  58672. * Gets or sets the highlight threshold
  58673. */
  58674. highlightsThreshold: number;
  58675. /**
  58676. * Sets the amount of blur at the edges
  58677. * @param amount blur amount
  58678. */
  58679. setEdgeBlur(amount: number): void;
  58680. /**
  58681. * Sets edge blur to 0
  58682. */
  58683. disableEdgeBlur(): void;
  58684. /**
  58685. * Sets the amout of grain
  58686. * @param amount Amount of grain
  58687. */
  58688. setGrainAmount(amount: number): void;
  58689. /**
  58690. * Set grain amount to 0
  58691. */
  58692. disableGrain(): void;
  58693. /**
  58694. * Sets the chromatic aberration amount
  58695. * @param amount amount of chromatic aberration
  58696. */
  58697. setChromaticAberration(amount: number): void;
  58698. /**
  58699. * Sets chromatic aberration amount to 0
  58700. */
  58701. disableChromaticAberration(): void;
  58702. /**
  58703. * Sets the EdgeDistortion amount
  58704. * @param amount amount of EdgeDistortion
  58705. */
  58706. setEdgeDistortion(amount: number): void;
  58707. /**
  58708. * Sets edge distortion to 0
  58709. */
  58710. disableEdgeDistortion(): void;
  58711. /**
  58712. * Sets the FocusDistance amount
  58713. * @param amount amount of FocusDistance
  58714. */
  58715. setFocusDistance(amount: number): void;
  58716. /**
  58717. * Disables depth of field
  58718. */
  58719. disableDepthOfField(): void;
  58720. /**
  58721. * Sets the Aperture amount
  58722. * @param amount amount of Aperture
  58723. */
  58724. setAperture(amount: number): void;
  58725. /**
  58726. * Sets the DarkenOutOfFocus amount
  58727. * @param amount amount of DarkenOutOfFocus
  58728. */
  58729. setDarkenOutOfFocus(amount: number): void;
  58730. private _pentagonBokehIsEnabled;
  58731. /**
  58732. * Creates a pentagon bokeh effect
  58733. */
  58734. enablePentagonBokeh(): void;
  58735. /**
  58736. * Disables the pentagon bokeh effect
  58737. */
  58738. disablePentagonBokeh(): void;
  58739. /**
  58740. * Enables noise blur
  58741. */
  58742. enableNoiseBlur(): void;
  58743. /**
  58744. * Disables noise blur
  58745. */
  58746. disableNoiseBlur(): void;
  58747. /**
  58748. * Sets the HighlightsGain amount
  58749. * @param amount amount of HighlightsGain
  58750. */
  58751. setHighlightsGain(amount: number): void;
  58752. /**
  58753. * Sets the HighlightsThreshold amount
  58754. * @param amount amount of HighlightsThreshold
  58755. */
  58756. setHighlightsThreshold(amount: number): void;
  58757. /**
  58758. * Disables highlights
  58759. */
  58760. disableHighlights(): void;
  58761. /**
  58762. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58763. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58764. */
  58765. dispose(disableDepthRender?: boolean): void;
  58766. private _createChromaticAberrationPostProcess;
  58767. private _createHighlightsPostProcess;
  58768. private _createDepthOfFieldPostProcess;
  58769. private _createGrainTexture;
  58770. }
  58771. }
  58772. declare module BABYLON {
  58773. /** @hidden */
  58774. export var ssao2PixelShader: {
  58775. name: string;
  58776. shader: string;
  58777. };
  58778. }
  58779. declare module BABYLON {
  58780. /** @hidden */
  58781. export var ssaoCombinePixelShader: {
  58782. name: string;
  58783. shader: string;
  58784. };
  58785. }
  58786. declare module BABYLON {
  58787. /**
  58788. * Render pipeline to produce ssao effect
  58789. */
  58790. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58791. /**
  58792. * @ignore
  58793. * The PassPostProcess id in the pipeline that contains the original scene color
  58794. */
  58795. SSAOOriginalSceneColorEffect: string;
  58796. /**
  58797. * @ignore
  58798. * The SSAO PostProcess id in the pipeline
  58799. */
  58800. SSAORenderEffect: string;
  58801. /**
  58802. * @ignore
  58803. * The horizontal blur PostProcess id in the pipeline
  58804. */
  58805. SSAOBlurHRenderEffect: string;
  58806. /**
  58807. * @ignore
  58808. * The vertical blur PostProcess id in the pipeline
  58809. */
  58810. SSAOBlurVRenderEffect: string;
  58811. /**
  58812. * @ignore
  58813. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58814. */
  58815. SSAOCombineRenderEffect: string;
  58816. /**
  58817. * The output strength of the SSAO post-process. Default value is 1.0.
  58818. */
  58819. totalStrength: number;
  58820. /**
  58821. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58822. */
  58823. maxZ: number;
  58824. /**
  58825. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58826. */
  58827. minZAspect: number;
  58828. private _samples;
  58829. /**
  58830. * Number of samples used for the SSAO calculations. Default value is 8
  58831. */
  58832. samples: number;
  58833. private _textureSamples;
  58834. /**
  58835. * Number of samples to use for antialiasing
  58836. */
  58837. textureSamples: number;
  58838. /**
  58839. * Ratio object used for SSAO ratio and blur ratio
  58840. */
  58841. private _ratio;
  58842. /**
  58843. * Dynamically generated sphere sampler.
  58844. */
  58845. private _sampleSphere;
  58846. /**
  58847. * Blur filter offsets
  58848. */
  58849. private _samplerOffsets;
  58850. private _expensiveBlur;
  58851. /**
  58852. * If bilateral blur should be used
  58853. */
  58854. expensiveBlur: boolean;
  58855. /**
  58856. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58857. */
  58858. radius: number;
  58859. /**
  58860. * The base color of the SSAO post-process
  58861. * The final result is "base + ssao" between [0, 1]
  58862. */
  58863. base: number;
  58864. /**
  58865. * Support test.
  58866. */
  58867. static readonly IsSupported: boolean;
  58868. private _scene;
  58869. private _depthTexture;
  58870. private _normalTexture;
  58871. private _randomTexture;
  58872. private _originalColorPostProcess;
  58873. private _ssaoPostProcess;
  58874. private _blurHPostProcess;
  58875. private _blurVPostProcess;
  58876. private _ssaoCombinePostProcess;
  58877. private _firstUpdate;
  58878. /**
  58879. * Gets active scene
  58880. */
  58881. readonly scene: Scene;
  58882. /**
  58883. * @constructor
  58884. * @param name The rendering pipeline name
  58885. * @param scene The scene linked to this pipeline
  58886. * @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 }
  58887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58888. */
  58889. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58890. /**
  58891. * Get the class name
  58892. * @returns "SSAO2RenderingPipeline"
  58893. */
  58894. getClassName(): string;
  58895. /**
  58896. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58897. */
  58898. dispose(disableGeometryBufferRenderer?: boolean): void;
  58899. private _createBlurPostProcess;
  58900. /** @hidden */
  58901. _rebuild(): void;
  58902. private _bits;
  58903. private _radicalInverse_VdC;
  58904. private _hammersley;
  58905. private _hemisphereSample_uniform;
  58906. private _generateHemisphere;
  58907. private _createSSAOPostProcess;
  58908. private _createSSAOCombinePostProcess;
  58909. private _createRandomTexture;
  58910. /**
  58911. * Serialize the rendering pipeline (Used when exporting)
  58912. * @returns the serialized object
  58913. */
  58914. serialize(): any;
  58915. /**
  58916. * Parse the serialized pipeline
  58917. * @param source Source pipeline.
  58918. * @param scene The scene to load the pipeline to.
  58919. * @param rootUrl The URL of the serialized pipeline.
  58920. * @returns An instantiated pipeline from the serialized object.
  58921. */
  58922. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58923. }
  58924. }
  58925. declare module BABYLON {
  58926. /** @hidden */
  58927. export var ssaoPixelShader: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module BABYLON {
  58933. /**
  58934. * Render pipeline to produce ssao effect
  58935. */
  58936. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58937. /**
  58938. * @ignore
  58939. * The PassPostProcess id in the pipeline that contains the original scene color
  58940. */
  58941. SSAOOriginalSceneColorEffect: string;
  58942. /**
  58943. * @ignore
  58944. * The SSAO PostProcess id in the pipeline
  58945. */
  58946. SSAORenderEffect: string;
  58947. /**
  58948. * @ignore
  58949. * The horizontal blur PostProcess id in the pipeline
  58950. */
  58951. SSAOBlurHRenderEffect: string;
  58952. /**
  58953. * @ignore
  58954. * The vertical blur PostProcess id in the pipeline
  58955. */
  58956. SSAOBlurVRenderEffect: string;
  58957. /**
  58958. * @ignore
  58959. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58960. */
  58961. SSAOCombineRenderEffect: string;
  58962. /**
  58963. * The output strength of the SSAO post-process. Default value is 1.0.
  58964. */
  58965. totalStrength: number;
  58966. /**
  58967. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58968. */
  58969. radius: number;
  58970. /**
  58971. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58972. * Must not be equal to fallOff and superior to fallOff.
  58973. * Default value is 0.0075
  58974. */
  58975. area: number;
  58976. /**
  58977. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58978. * Must not be equal to area and inferior to area.
  58979. * Default value is 0.000001
  58980. */
  58981. fallOff: number;
  58982. /**
  58983. * The base color of the SSAO post-process
  58984. * The final result is "base + ssao" between [0, 1]
  58985. */
  58986. base: number;
  58987. private _scene;
  58988. private _depthTexture;
  58989. private _randomTexture;
  58990. private _originalColorPostProcess;
  58991. private _ssaoPostProcess;
  58992. private _blurHPostProcess;
  58993. private _blurVPostProcess;
  58994. private _ssaoCombinePostProcess;
  58995. private _firstUpdate;
  58996. /**
  58997. * Gets active scene
  58998. */
  58999. readonly scene: Scene;
  59000. /**
  59001. * @constructor
  59002. * @param name - The rendering pipeline name
  59003. * @param scene - The scene linked to this pipeline
  59004. * @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 }
  59005. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59006. */
  59007. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59008. /**
  59009. * Get the class name
  59010. * @returns "SSAORenderingPipeline"
  59011. */
  59012. getClassName(): string;
  59013. /**
  59014. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59015. */
  59016. dispose(disableDepthRender?: boolean): void;
  59017. private _createBlurPostProcess;
  59018. /** @hidden */
  59019. _rebuild(): void;
  59020. private _createSSAOPostProcess;
  59021. private _createSSAOCombinePostProcess;
  59022. private _createRandomTexture;
  59023. }
  59024. }
  59025. declare module BABYLON {
  59026. /** @hidden */
  59027. export var standardPixelShader: {
  59028. name: string;
  59029. shader: string;
  59030. };
  59031. }
  59032. declare module BABYLON {
  59033. /**
  59034. * Standard rendering pipeline
  59035. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59036. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59037. */
  59038. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59039. /**
  59040. * Public members
  59041. */
  59042. /**
  59043. * Post-process which contains the original scene color before the pipeline applies all the effects
  59044. */
  59045. originalPostProcess: Nullable<PostProcess>;
  59046. /**
  59047. * Post-process used to down scale an image x4
  59048. */
  59049. downSampleX4PostProcess: Nullable<PostProcess>;
  59050. /**
  59051. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59052. */
  59053. brightPassPostProcess: Nullable<PostProcess>;
  59054. /**
  59055. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59056. */
  59057. blurHPostProcesses: PostProcess[];
  59058. /**
  59059. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59060. */
  59061. blurVPostProcesses: PostProcess[];
  59062. /**
  59063. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59064. */
  59065. textureAdderPostProcess: Nullable<PostProcess>;
  59066. /**
  59067. * Post-process used to create volumetric lighting effect
  59068. */
  59069. volumetricLightPostProcess: Nullable<PostProcess>;
  59070. /**
  59071. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59072. */
  59073. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59074. /**
  59075. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59076. */
  59077. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59078. /**
  59079. * Post-process used to merge the volumetric light effect and the real scene color
  59080. */
  59081. volumetricLightMergePostProces: Nullable<PostProcess>;
  59082. /**
  59083. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59084. */
  59085. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59086. /**
  59087. * Base post-process used to calculate the average luminance of the final image for HDR
  59088. */
  59089. luminancePostProcess: Nullable<PostProcess>;
  59090. /**
  59091. * Post-processes used to create down sample post-processes in order to get
  59092. * the average luminance of the final image for HDR
  59093. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59094. */
  59095. luminanceDownSamplePostProcesses: PostProcess[];
  59096. /**
  59097. * Post-process used to create a HDR effect (light adaptation)
  59098. */
  59099. hdrPostProcess: Nullable<PostProcess>;
  59100. /**
  59101. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59102. */
  59103. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59104. /**
  59105. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59106. */
  59107. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59108. /**
  59109. * Post-process used to merge the final HDR post-process and the real scene color
  59110. */
  59111. hdrFinalPostProcess: Nullable<PostProcess>;
  59112. /**
  59113. * Post-process used to create a lens flare effect
  59114. */
  59115. lensFlarePostProcess: Nullable<PostProcess>;
  59116. /**
  59117. * Post-process that merges the result of the lens flare post-process and the real scene color
  59118. */
  59119. lensFlareComposePostProcess: Nullable<PostProcess>;
  59120. /**
  59121. * Post-process used to create a motion blur effect
  59122. */
  59123. motionBlurPostProcess: Nullable<PostProcess>;
  59124. /**
  59125. * Post-process used to create a depth of field effect
  59126. */
  59127. depthOfFieldPostProcess: Nullable<PostProcess>;
  59128. /**
  59129. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59130. */
  59131. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59132. /**
  59133. * Represents the brightness threshold in order to configure the illuminated surfaces
  59134. */
  59135. brightThreshold: number;
  59136. /**
  59137. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59138. */
  59139. blurWidth: number;
  59140. /**
  59141. * Sets if the blur for highlighted surfaces must be only horizontal
  59142. */
  59143. horizontalBlur: boolean;
  59144. /**
  59145. * Gets the overall exposure used by the pipeline
  59146. */
  59147. /**
  59148. * Sets the overall exposure used by the pipeline
  59149. */
  59150. exposure: number;
  59151. /**
  59152. * Texture used typically to simulate "dirty" on camera lens
  59153. */
  59154. lensTexture: Nullable<Texture>;
  59155. /**
  59156. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59157. */
  59158. volumetricLightCoefficient: number;
  59159. /**
  59160. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59161. */
  59162. volumetricLightPower: number;
  59163. /**
  59164. * Used the set the blur intensity to smooth the volumetric lights
  59165. */
  59166. volumetricLightBlurScale: number;
  59167. /**
  59168. * Light (spot or directional) used to generate the volumetric lights rays
  59169. * The source light must have a shadow generate so the pipeline can get its
  59170. * depth map
  59171. */
  59172. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59173. /**
  59174. * For eye adaptation, represents the minimum luminance the eye can see
  59175. */
  59176. hdrMinimumLuminance: number;
  59177. /**
  59178. * For eye adaptation, represents the decrease luminance speed
  59179. */
  59180. hdrDecreaseRate: number;
  59181. /**
  59182. * For eye adaptation, represents the increase luminance speed
  59183. */
  59184. hdrIncreaseRate: number;
  59185. /**
  59186. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59187. */
  59188. /**
  59189. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59190. */
  59191. hdrAutoExposure: boolean;
  59192. /**
  59193. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59194. */
  59195. lensColorTexture: Nullable<Texture>;
  59196. /**
  59197. * The overall strengh for the lens flare effect
  59198. */
  59199. lensFlareStrength: number;
  59200. /**
  59201. * Dispersion coefficient for lens flare ghosts
  59202. */
  59203. lensFlareGhostDispersal: number;
  59204. /**
  59205. * Main lens flare halo width
  59206. */
  59207. lensFlareHaloWidth: number;
  59208. /**
  59209. * Based on the lens distortion effect, defines how much the lens flare result
  59210. * is distorted
  59211. */
  59212. lensFlareDistortionStrength: number;
  59213. /**
  59214. * Configures the blur intensity used for for lens flare (halo)
  59215. */
  59216. lensFlareBlurWidth: number;
  59217. /**
  59218. * Lens star texture must be used to simulate rays on the flares and is available
  59219. * in the documentation
  59220. */
  59221. lensStarTexture: Nullable<Texture>;
  59222. /**
  59223. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59224. * flare effect by taking account of the dirt texture
  59225. */
  59226. lensFlareDirtTexture: Nullable<Texture>;
  59227. /**
  59228. * Represents the focal length for the depth of field effect
  59229. */
  59230. depthOfFieldDistance: number;
  59231. /**
  59232. * Represents the blur intensity for the blurred part of the depth of field effect
  59233. */
  59234. depthOfFieldBlurWidth: number;
  59235. /**
  59236. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59237. */
  59238. /**
  59239. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59240. */
  59241. motionStrength: number;
  59242. /**
  59243. * Gets wether or not the motion blur post-process is object based or screen based.
  59244. */
  59245. /**
  59246. * Sets wether or not the motion blur post-process should be object based or screen based
  59247. */
  59248. objectBasedMotionBlur: boolean;
  59249. /**
  59250. * List of animations for the pipeline (IAnimatable implementation)
  59251. */
  59252. animations: Animation[];
  59253. /**
  59254. * Private members
  59255. */
  59256. private _scene;
  59257. private _currentDepthOfFieldSource;
  59258. private _basePostProcess;
  59259. private _fixedExposure;
  59260. private _currentExposure;
  59261. private _hdrAutoExposure;
  59262. private _hdrCurrentLuminance;
  59263. private _motionStrength;
  59264. private _isObjectBasedMotionBlur;
  59265. private _floatTextureType;
  59266. private _camerasToBeAttached;
  59267. private _ratio;
  59268. private _bloomEnabled;
  59269. private _depthOfFieldEnabled;
  59270. private _vlsEnabled;
  59271. private _lensFlareEnabled;
  59272. private _hdrEnabled;
  59273. private _motionBlurEnabled;
  59274. private _fxaaEnabled;
  59275. private _motionBlurSamples;
  59276. private _volumetricLightStepsCount;
  59277. private _samples;
  59278. /**
  59279. * @ignore
  59280. * Specifies if the bloom pipeline is enabled
  59281. */
  59282. BloomEnabled: boolean;
  59283. /**
  59284. * @ignore
  59285. * Specifies if the depth of field pipeline is enabed
  59286. */
  59287. DepthOfFieldEnabled: boolean;
  59288. /**
  59289. * @ignore
  59290. * Specifies if the lens flare pipeline is enabed
  59291. */
  59292. LensFlareEnabled: boolean;
  59293. /**
  59294. * @ignore
  59295. * Specifies if the HDR pipeline is enabled
  59296. */
  59297. HDREnabled: boolean;
  59298. /**
  59299. * @ignore
  59300. * Specifies if the volumetric lights scattering effect is enabled
  59301. */
  59302. VLSEnabled: boolean;
  59303. /**
  59304. * @ignore
  59305. * Specifies if the motion blur effect is enabled
  59306. */
  59307. MotionBlurEnabled: boolean;
  59308. /**
  59309. * Specifies if anti-aliasing is enabled
  59310. */
  59311. fxaaEnabled: boolean;
  59312. /**
  59313. * Specifies the number of steps used to calculate the volumetric lights
  59314. * Typically in interval [50, 200]
  59315. */
  59316. volumetricLightStepsCount: number;
  59317. /**
  59318. * Specifies the number of samples used for the motion blur effect
  59319. * Typically in interval [16, 64]
  59320. */
  59321. motionBlurSamples: number;
  59322. /**
  59323. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59324. */
  59325. samples: number;
  59326. /**
  59327. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59328. * @constructor
  59329. * @param name The rendering pipeline name
  59330. * @param scene The scene linked to this pipeline
  59331. * @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)
  59332. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59334. */
  59335. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59336. private _buildPipeline;
  59337. private _createDownSampleX4PostProcess;
  59338. private _createBrightPassPostProcess;
  59339. private _createBlurPostProcesses;
  59340. private _createTextureAdderPostProcess;
  59341. private _createVolumetricLightPostProcess;
  59342. private _createLuminancePostProcesses;
  59343. private _createHdrPostProcess;
  59344. private _createLensFlarePostProcess;
  59345. private _createDepthOfFieldPostProcess;
  59346. private _createMotionBlurPostProcess;
  59347. private _getDepthTexture;
  59348. private _disposePostProcesses;
  59349. /**
  59350. * Dispose of the pipeline and stop all post processes
  59351. */
  59352. dispose(): void;
  59353. /**
  59354. * Serialize the rendering pipeline (Used when exporting)
  59355. * @returns the serialized object
  59356. */
  59357. serialize(): any;
  59358. /**
  59359. * Parse the serialized pipeline
  59360. * @param source Source pipeline.
  59361. * @param scene The scene to load the pipeline to.
  59362. * @param rootUrl The URL of the serialized pipeline.
  59363. * @returns An instantiated pipeline from the serialized object.
  59364. */
  59365. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59366. /**
  59367. * Luminance steps
  59368. */
  59369. static LuminanceSteps: number;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /** @hidden */
  59374. export var tonemapPixelShader: {
  59375. name: string;
  59376. shader: string;
  59377. };
  59378. }
  59379. declare module BABYLON {
  59380. /** Defines operator used for tonemapping */
  59381. export enum TonemappingOperator {
  59382. /** Hable */
  59383. Hable = 0,
  59384. /** Reinhard */
  59385. Reinhard = 1,
  59386. /** HejiDawson */
  59387. HejiDawson = 2,
  59388. /** Photographic */
  59389. Photographic = 3
  59390. }
  59391. /**
  59392. * Defines a post process to apply tone mapping
  59393. */
  59394. export class TonemapPostProcess extends PostProcess {
  59395. private _operator;
  59396. /** Defines the required exposure adjustement */
  59397. exposureAdjustment: number;
  59398. /**
  59399. * Creates a new TonemapPostProcess
  59400. * @param name defines the name of the postprocess
  59401. * @param _operator defines the operator to use
  59402. * @param exposureAdjustment defines the required exposure adjustement
  59403. * @param camera defines the camera to use (can be null)
  59404. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59405. * @param engine defines the hosting engine (can be ignore if camera is set)
  59406. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59407. */
  59408. constructor(name: string, _operator: TonemappingOperator,
  59409. /** Defines the required exposure adjustement */
  59410. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59411. }
  59412. }
  59413. declare module BABYLON {
  59414. /** @hidden */
  59415. export var depthVertexShader: {
  59416. name: string;
  59417. shader: string;
  59418. };
  59419. }
  59420. declare module BABYLON {
  59421. /** @hidden */
  59422. export var volumetricLightScatteringPixelShader: {
  59423. name: string;
  59424. shader: string;
  59425. };
  59426. }
  59427. declare module BABYLON {
  59428. /** @hidden */
  59429. export var volumetricLightScatteringPassVertexShader: {
  59430. name: string;
  59431. shader: string;
  59432. };
  59433. }
  59434. declare module BABYLON {
  59435. /** @hidden */
  59436. export var volumetricLightScatteringPassPixelShader: {
  59437. name: string;
  59438. shader: string;
  59439. };
  59440. }
  59441. declare module BABYLON {
  59442. /**
  59443. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59444. */
  59445. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59446. private _volumetricLightScatteringPass;
  59447. private _volumetricLightScatteringRTT;
  59448. private _viewPort;
  59449. private _screenCoordinates;
  59450. private _cachedDefines;
  59451. /**
  59452. * If not undefined, the mesh position is computed from the attached node position
  59453. */
  59454. attachedNode: {
  59455. position: Vector3;
  59456. };
  59457. /**
  59458. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59459. */
  59460. customMeshPosition: Vector3;
  59461. /**
  59462. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59463. */
  59464. useCustomMeshPosition: boolean;
  59465. /**
  59466. * If the post-process should inverse the light scattering direction
  59467. */
  59468. invert: boolean;
  59469. /**
  59470. * The internal mesh used by the post-process
  59471. */
  59472. mesh: Mesh;
  59473. /**
  59474. * @hidden
  59475. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59476. */
  59477. useDiffuseColor: boolean;
  59478. /**
  59479. * Array containing the excluded meshes not rendered in the internal pass
  59480. */
  59481. excludedMeshes: AbstractMesh[];
  59482. /**
  59483. * Controls the overall intensity of the post-process
  59484. */
  59485. exposure: number;
  59486. /**
  59487. * Dissipates each sample's contribution in range [0, 1]
  59488. */
  59489. decay: number;
  59490. /**
  59491. * Controls the overall intensity of each sample
  59492. */
  59493. weight: number;
  59494. /**
  59495. * Controls the density of each sample
  59496. */
  59497. density: number;
  59498. /**
  59499. * @constructor
  59500. * @param name The post-process name
  59501. * @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)
  59502. * @param camera The camera that the post-process will be attached to
  59503. * @param mesh The mesh used to create the light scattering
  59504. * @param samples The post-process quality, default 100
  59505. * @param samplingModeThe post-process filtering mode
  59506. * @param engine The babylon engine
  59507. * @param reusable If the post-process is reusable
  59508. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59509. */
  59510. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59511. /**
  59512. * Returns the string "VolumetricLightScatteringPostProcess"
  59513. * @returns "VolumetricLightScatteringPostProcess"
  59514. */
  59515. getClassName(): string;
  59516. private _isReady;
  59517. /**
  59518. * Sets the new light position for light scattering effect
  59519. * @param position The new custom light position
  59520. */
  59521. setCustomMeshPosition(position: Vector3): void;
  59522. /**
  59523. * Returns the light position for light scattering effect
  59524. * @return Vector3 The custom light position
  59525. */
  59526. getCustomMeshPosition(): Vector3;
  59527. /**
  59528. * Disposes the internal assets and detaches the post-process from the camera
  59529. */
  59530. dispose(camera: Camera): void;
  59531. /**
  59532. * Returns the render target texture used by the post-process
  59533. * @return the render target texture used by the post-process
  59534. */
  59535. getPass(): RenderTargetTexture;
  59536. private _meshExcluded;
  59537. private _createPass;
  59538. private _updateMeshScreenCoordinates;
  59539. /**
  59540. * Creates a default mesh for the Volumeric Light Scattering post-process
  59541. * @param name The mesh name
  59542. * @param scene The scene where to create the mesh
  59543. * @return the default mesh
  59544. */
  59545. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59546. }
  59547. }
  59548. declare module BABYLON {
  59549. interface Scene {
  59550. /** @hidden (Backing field) */
  59551. _boundingBoxRenderer: BoundingBoxRenderer;
  59552. /** @hidden (Backing field) */
  59553. _forceShowBoundingBoxes: boolean;
  59554. /**
  59555. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59556. */
  59557. forceShowBoundingBoxes: boolean;
  59558. /**
  59559. * Gets the bounding box renderer associated with the scene
  59560. * @returns a BoundingBoxRenderer
  59561. */
  59562. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59563. }
  59564. interface AbstractMesh {
  59565. /** @hidden (Backing field) */
  59566. _showBoundingBox: boolean;
  59567. /**
  59568. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59569. */
  59570. showBoundingBox: boolean;
  59571. }
  59572. /**
  59573. * Component responsible of rendering the bounding box of the meshes in a scene.
  59574. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59575. */
  59576. export class BoundingBoxRenderer implements ISceneComponent {
  59577. /**
  59578. * The component name helpfull to identify the component in the list of scene components.
  59579. */
  59580. readonly name: string;
  59581. /**
  59582. * The scene the component belongs to.
  59583. */
  59584. scene: Scene;
  59585. /**
  59586. * Color of the bounding box lines placed in front of an object
  59587. */
  59588. frontColor: Color3;
  59589. /**
  59590. * Color of the bounding box lines placed behind an object
  59591. */
  59592. backColor: Color3;
  59593. /**
  59594. * Defines if the renderer should show the back lines or not
  59595. */
  59596. showBackLines: boolean;
  59597. /**
  59598. * @hidden
  59599. */
  59600. renderList: SmartArray<BoundingBox>;
  59601. private _colorShader;
  59602. private _vertexBuffers;
  59603. private _indexBuffer;
  59604. private _fillIndexBuffer;
  59605. private _fillIndexData;
  59606. /**
  59607. * Instantiates a new bounding box renderer in a scene.
  59608. * @param scene the scene the renderer renders in
  59609. */
  59610. constructor(scene: Scene);
  59611. /**
  59612. * Registers the component in a given scene
  59613. */
  59614. register(): void;
  59615. private _evaluateSubMesh;
  59616. private _activeMesh;
  59617. private _prepareRessources;
  59618. private _createIndexBuffer;
  59619. /**
  59620. * Rebuilds the elements related to this component in case of
  59621. * context lost for instance.
  59622. */
  59623. rebuild(): void;
  59624. /**
  59625. * @hidden
  59626. */
  59627. reset(): void;
  59628. /**
  59629. * Render the bounding boxes of a specific rendering group
  59630. * @param renderingGroupId defines the rendering group to render
  59631. */
  59632. render(renderingGroupId: number): void;
  59633. /**
  59634. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59635. * @param mesh Define the mesh to render the occlusion bounding box for
  59636. */
  59637. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59638. /**
  59639. * Dispose and release the resources attached to this renderer.
  59640. */
  59641. dispose(): void;
  59642. }
  59643. }
  59644. declare module BABYLON {
  59645. /** @hidden */
  59646. export var depthPixelShader: {
  59647. name: string;
  59648. shader: string;
  59649. };
  59650. }
  59651. declare module BABYLON {
  59652. /**
  59653. * This represents a depth renderer in Babylon.
  59654. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59655. */
  59656. export class DepthRenderer {
  59657. private _scene;
  59658. private _depthMap;
  59659. private _effect;
  59660. private readonly _storeNonLinearDepth;
  59661. private readonly _clearColor;
  59662. /** Get if the depth renderer is using packed depth or not */
  59663. readonly isPacked: boolean;
  59664. private _cachedDefines;
  59665. private _camera;
  59666. /**
  59667. * Specifiess that the depth renderer will only be used within
  59668. * the camera it is created for.
  59669. * This can help forcing its rendering during the camera processing.
  59670. */
  59671. useOnlyInActiveCamera: boolean;
  59672. /** @hidden */
  59673. static _SceneComponentInitialization: (scene: Scene) => void;
  59674. /**
  59675. * Instantiates a depth renderer
  59676. * @param scene The scene the renderer belongs to
  59677. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59678. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59679. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59680. */
  59681. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59682. /**
  59683. * Creates the depth rendering effect and checks if the effect is ready.
  59684. * @param subMesh The submesh to be used to render the depth map of
  59685. * @param useInstances If multiple world instances should be used
  59686. * @returns if the depth renderer is ready to render the depth map
  59687. */
  59688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59689. /**
  59690. * Gets the texture which the depth map will be written to.
  59691. * @returns The depth map texture
  59692. */
  59693. getDepthMap(): RenderTargetTexture;
  59694. /**
  59695. * Disposes of the depth renderer.
  59696. */
  59697. dispose(): void;
  59698. }
  59699. }
  59700. declare module BABYLON {
  59701. interface Scene {
  59702. /** @hidden (Backing field) */
  59703. _depthRenderer: {
  59704. [id: string]: DepthRenderer;
  59705. };
  59706. /**
  59707. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59708. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59709. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59710. * @returns the created depth renderer
  59711. */
  59712. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  59713. /**
  59714. * Disables a depth renderer for a given camera
  59715. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59716. */
  59717. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59718. }
  59719. /**
  59720. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59721. * in several rendering techniques.
  59722. */
  59723. export class DepthRendererSceneComponent implements ISceneComponent {
  59724. /**
  59725. * The component name helpfull to identify the component in the list of scene components.
  59726. */
  59727. readonly name: string;
  59728. /**
  59729. * The scene the component belongs to.
  59730. */
  59731. scene: Scene;
  59732. /**
  59733. * Creates a new instance of the component for the given scene
  59734. * @param scene Defines the scene to register the component in
  59735. */
  59736. constructor(scene: Scene);
  59737. /**
  59738. * Registers the component in a given scene
  59739. */
  59740. register(): void;
  59741. /**
  59742. * Rebuilds the elements related to this component in case of
  59743. * context lost for instance.
  59744. */
  59745. rebuild(): void;
  59746. /**
  59747. * Disposes the component and the associated ressources
  59748. */
  59749. dispose(): void;
  59750. private _gatherRenderTargets;
  59751. private _gatherActiveCameraRenderTargets;
  59752. }
  59753. }
  59754. declare module BABYLON {
  59755. /** @hidden */
  59756. export var outlinePixelShader: {
  59757. name: string;
  59758. shader: string;
  59759. };
  59760. }
  59761. declare module BABYLON {
  59762. /** @hidden */
  59763. export var outlineVertexShader: {
  59764. name: string;
  59765. shader: string;
  59766. };
  59767. }
  59768. declare module BABYLON {
  59769. interface Scene {
  59770. /** @hidden */
  59771. _outlineRenderer: OutlineRenderer;
  59772. /**
  59773. * Gets the outline renderer associated with the scene
  59774. * @returns a OutlineRenderer
  59775. */
  59776. getOutlineRenderer(): OutlineRenderer;
  59777. }
  59778. interface AbstractMesh {
  59779. /** @hidden (Backing field) */
  59780. _renderOutline: boolean;
  59781. /**
  59782. * Gets or sets a boolean indicating if the outline must be rendered as well
  59783. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59784. */
  59785. renderOutline: boolean;
  59786. /** @hidden (Backing field) */
  59787. _renderOverlay: boolean;
  59788. /**
  59789. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59790. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59791. */
  59792. renderOverlay: boolean;
  59793. }
  59794. /**
  59795. * This class is responsible to draw bothe outline/overlay of meshes.
  59796. * It should not be used directly but through the available method on mesh.
  59797. */
  59798. export class OutlineRenderer implements ISceneComponent {
  59799. /**
  59800. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59801. */
  59802. private static _StencilReference;
  59803. /**
  59804. * The name of the component. Each component must have a unique name.
  59805. */
  59806. name: string;
  59807. /**
  59808. * The scene the component belongs to.
  59809. */
  59810. scene: Scene;
  59811. /**
  59812. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59813. */
  59814. zOffset: number;
  59815. private _engine;
  59816. private _effect;
  59817. private _cachedDefines;
  59818. private _savedDepthWrite;
  59819. /**
  59820. * Instantiates a new outline renderer. (There could be only one per scene).
  59821. * @param scene Defines the scene it belongs to
  59822. */
  59823. constructor(scene: Scene);
  59824. /**
  59825. * Register the component to one instance of a scene.
  59826. */
  59827. register(): void;
  59828. /**
  59829. * Rebuilds the elements related to this component in case of
  59830. * context lost for instance.
  59831. */
  59832. rebuild(): void;
  59833. /**
  59834. * Disposes the component and the associated ressources.
  59835. */
  59836. dispose(): void;
  59837. /**
  59838. * Renders the outline in the canvas.
  59839. * @param subMesh Defines the sumesh to render
  59840. * @param batch Defines the batch of meshes in case of instances
  59841. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59842. */
  59843. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59844. /**
  59845. * Returns whether or not the outline renderer is ready for a given submesh.
  59846. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59847. * @param subMesh Defines the submesh to check readyness for
  59848. * @param useInstances Defines wheter wee are trying to render instances or not
  59849. * @returns true if ready otherwise false
  59850. */
  59851. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59852. private _beforeRenderingMesh;
  59853. private _afterRenderingMesh;
  59854. }
  59855. }
  59856. declare module BABYLON {
  59857. /**
  59858. * Class used to manage multiple sprites of different sizes on the same spritesheet
  59859. * @see http://doc.babylonjs.com/babylon101/sprites
  59860. */
  59861. export class SpritePackedManager extends SpriteManager {
  59862. /** defines the packed manager's name */
  59863. name: string;
  59864. /**
  59865. * Creates a new sprite manager from a packed sprite sheet
  59866. * @param name defines the manager's name
  59867. * @param imgUrl defines the sprite sheet url
  59868. * @param capacity defines the maximum allowed number of sprites
  59869. * @param scene defines the hosting scene
  59870. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  59871. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  59872. * @param samplingMode defines the smapling mode to use with spritesheet
  59873. * @param fromPacked set to true; do not alter
  59874. */
  59875. constructor(
  59876. /** defines the packed manager's name */
  59877. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  59878. }
  59879. }
  59880. declare module BABYLON {
  59881. /**
  59882. * Defines the list of states available for a task inside a AssetsManager
  59883. */
  59884. export enum AssetTaskState {
  59885. /**
  59886. * Initialization
  59887. */
  59888. INIT = 0,
  59889. /**
  59890. * Running
  59891. */
  59892. RUNNING = 1,
  59893. /**
  59894. * Done
  59895. */
  59896. DONE = 2,
  59897. /**
  59898. * Error
  59899. */
  59900. ERROR = 3
  59901. }
  59902. /**
  59903. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59904. */
  59905. export abstract class AbstractAssetTask {
  59906. /**
  59907. * Task name
  59908. */ name: string;
  59909. /**
  59910. * Callback called when the task is successful
  59911. */
  59912. onSuccess: (task: any) => void;
  59913. /**
  59914. * Callback called when the task is not successful
  59915. */
  59916. onError: (task: any, message?: string, exception?: any) => void;
  59917. /**
  59918. * Creates a new AssetsManager
  59919. * @param name defines the name of the task
  59920. */
  59921. constructor(
  59922. /**
  59923. * Task name
  59924. */ name: string);
  59925. private _isCompleted;
  59926. private _taskState;
  59927. private _errorObject;
  59928. /**
  59929. * Get if the task is completed
  59930. */
  59931. readonly isCompleted: boolean;
  59932. /**
  59933. * Gets the current state of the task
  59934. */
  59935. readonly taskState: AssetTaskState;
  59936. /**
  59937. * Gets the current error object (if task is in error)
  59938. */
  59939. readonly errorObject: {
  59940. message?: string;
  59941. exception?: any;
  59942. };
  59943. /**
  59944. * Internal only
  59945. * @hidden
  59946. */
  59947. _setErrorObject(message?: string, exception?: any): void;
  59948. /**
  59949. * Execute the current task
  59950. * @param scene defines the scene where you want your assets to be loaded
  59951. * @param onSuccess is a callback called when the task is successfully executed
  59952. * @param onError is a callback called if an error occurs
  59953. */
  59954. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59955. /**
  59956. * Execute the current task
  59957. * @param scene defines the scene where you want your assets to be loaded
  59958. * @param onSuccess is a callback called when the task is successfully executed
  59959. * @param onError is a callback called if an error occurs
  59960. */
  59961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59962. /**
  59963. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59964. * This can be used with failed tasks that have the reason for failure fixed.
  59965. */
  59966. reset(): void;
  59967. private onErrorCallback;
  59968. private onDoneCallback;
  59969. }
  59970. /**
  59971. * Define the interface used by progress events raised during assets loading
  59972. */
  59973. export interface IAssetsProgressEvent {
  59974. /**
  59975. * Defines the number of remaining tasks to process
  59976. */
  59977. remainingCount: number;
  59978. /**
  59979. * Defines the total number of tasks
  59980. */
  59981. totalCount: number;
  59982. /**
  59983. * Defines the task that was just processed
  59984. */
  59985. task: AbstractAssetTask;
  59986. }
  59987. /**
  59988. * Class used to share progress information about assets loading
  59989. */
  59990. export class AssetsProgressEvent implements IAssetsProgressEvent {
  59991. /**
  59992. * Defines the number of remaining tasks to process
  59993. */
  59994. remainingCount: number;
  59995. /**
  59996. * Defines the total number of tasks
  59997. */
  59998. totalCount: number;
  59999. /**
  60000. * Defines the task that was just processed
  60001. */
  60002. task: AbstractAssetTask;
  60003. /**
  60004. * Creates a AssetsProgressEvent
  60005. * @param remainingCount defines the number of remaining tasks to process
  60006. * @param totalCount defines the total number of tasks
  60007. * @param task defines the task that was just processed
  60008. */
  60009. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60010. }
  60011. /**
  60012. * Define a task used by AssetsManager to load meshes
  60013. */
  60014. export class MeshAssetTask extends AbstractAssetTask {
  60015. /**
  60016. * Defines the name of the task
  60017. */
  60018. name: string;
  60019. /**
  60020. * Defines the list of mesh's names you want to load
  60021. */
  60022. meshesNames: any;
  60023. /**
  60024. * Defines the root url to use as a base to load your meshes and associated resources
  60025. */
  60026. rootUrl: string;
  60027. /**
  60028. * Defines the filename of the scene to load from
  60029. */
  60030. sceneFilename: string;
  60031. /**
  60032. * Gets the list of loaded meshes
  60033. */
  60034. loadedMeshes: Array<AbstractMesh>;
  60035. /**
  60036. * Gets the list of loaded particle systems
  60037. */
  60038. loadedParticleSystems: Array<IParticleSystem>;
  60039. /**
  60040. * Gets the list of loaded skeletons
  60041. */
  60042. loadedSkeletons: Array<Skeleton>;
  60043. /**
  60044. * Gets the list of loaded animation groups
  60045. */
  60046. loadedAnimationGroups: Array<AnimationGroup>;
  60047. /**
  60048. * Callback called when the task is successful
  60049. */
  60050. onSuccess: (task: MeshAssetTask) => void;
  60051. /**
  60052. * Callback called when the task is successful
  60053. */
  60054. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60055. /**
  60056. * Creates a new MeshAssetTask
  60057. * @param name defines the name of the task
  60058. * @param meshesNames defines the list of mesh's names you want to load
  60059. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60060. * @param sceneFilename defines the filename of the scene to load from
  60061. */
  60062. constructor(
  60063. /**
  60064. * Defines the name of the task
  60065. */
  60066. name: string,
  60067. /**
  60068. * Defines the list of mesh's names you want to load
  60069. */
  60070. meshesNames: any,
  60071. /**
  60072. * Defines the root url to use as a base to load your meshes and associated resources
  60073. */
  60074. rootUrl: string,
  60075. /**
  60076. * Defines the filename of the scene to load from
  60077. */
  60078. sceneFilename: string);
  60079. /**
  60080. * Execute the current task
  60081. * @param scene defines the scene where you want your assets to be loaded
  60082. * @param onSuccess is a callback called when the task is successfully executed
  60083. * @param onError is a callback called if an error occurs
  60084. */
  60085. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60086. }
  60087. /**
  60088. * Define a task used by AssetsManager to load text content
  60089. */
  60090. export class TextFileAssetTask extends AbstractAssetTask {
  60091. /**
  60092. * Defines the name of the task
  60093. */
  60094. name: string;
  60095. /**
  60096. * Defines the location of the file to load
  60097. */
  60098. url: string;
  60099. /**
  60100. * Gets the loaded text string
  60101. */
  60102. text: string;
  60103. /**
  60104. * Callback called when the task is successful
  60105. */
  60106. onSuccess: (task: TextFileAssetTask) => void;
  60107. /**
  60108. * Callback called when the task is successful
  60109. */
  60110. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60111. /**
  60112. * Creates a new TextFileAssetTask object
  60113. * @param name defines the name of the task
  60114. * @param url defines the location of the file to load
  60115. */
  60116. constructor(
  60117. /**
  60118. * Defines the name of the task
  60119. */
  60120. name: string,
  60121. /**
  60122. * Defines the location of the file to load
  60123. */
  60124. url: string);
  60125. /**
  60126. * Execute the current task
  60127. * @param scene defines the scene where you want your assets to be loaded
  60128. * @param onSuccess is a callback called when the task is successfully executed
  60129. * @param onError is a callback called if an error occurs
  60130. */
  60131. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60132. }
  60133. /**
  60134. * Define a task used by AssetsManager to load binary data
  60135. */
  60136. export class BinaryFileAssetTask extends AbstractAssetTask {
  60137. /**
  60138. * Defines the name of the task
  60139. */
  60140. name: string;
  60141. /**
  60142. * Defines the location of the file to load
  60143. */
  60144. url: string;
  60145. /**
  60146. * Gets the lodaded data (as an array buffer)
  60147. */
  60148. data: ArrayBuffer;
  60149. /**
  60150. * Callback called when the task is successful
  60151. */
  60152. onSuccess: (task: BinaryFileAssetTask) => void;
  60153. /**
  60154. * Callback called when the task is successful
  60155. */
  60156. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60157. /**
  60158. * Creates a new BinaryFileAssetTask object
  60159. * @param name defines the name of the new task
  60160. * @param url defines the location of the file to load
  60161. */
  60162. constructor(
  60163. /**
  60164. * Defines the name of the task
  60165. */
  60166. name: string,
  60167. /**
  60168. * Defines the location of the file to load
  60169. */
  60170. url: string);
  60171. /**
  60172. * Execute the current task
  60173. * @param scene defines the scene where you want your assets to be loaded
  60174. * @param onSuccess is a callback called when the task is successfully executed
  60175. * @param onError is a callback called if an error occurs
  60176. */
  60177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60178. }
  60179. /**
  60180. * Define a task used by AssetsManager to load images
  60181. */
  60182. export class ImageAssetTask extends AbstractAssetTask {
  60183. /**
  60184. * Defines the name of the task
  60185. */
  60186. name: string;
  60187. /**
  60188. * Defines the location of the image to load
  60189. */
  60190. url: string;
  60191. /**
  60192. * Gets the loaded images
  60193. */
  60194. image: HTMLImageElement;
  60195. /**
  60196. * Callback called when the task is successful
  60197. */
  60198. onSuccess: (task: ImageAssetTask) => void;
  60199. /**
  60200. * Callback called when the task is successful
  60201. */
  60202. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60203. /**
  60204. * Creates a new ImageAssetTask
  60205. * @param name defines the name of the task
  60206. * @param url defines the location of the image to load
  60207. */
  60208. constructor(
  60209. /**
  60210. * Defines the name of the task
  60211. */
  60212. name: string,
  60213. /**
  60214. * Defines the location of the image to load
  60215. */
  60216. url: string);
  60217. /**
  60218. * Execute the current task
  60219. * @param scene defines the scene where you want your assets to be loaded
  60220. * @param onSuccess is a callback called when the task is successfully executed
  60221. * @param onError is a callback called if an error occurs
  60222. */
  60223. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60224. }
  60225. /**
  60226. * Defines the interface used by texture loading tasks
  60227. */
  60228. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60229. /**
  60230. * Gets the loaded texture
  60231. */
  60232. texture: TEX;
  60233. }
  60234. /**
  60235. * Define a task used by AssetsManager to load 2D textures
  60236. */
  60237. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60238. /**
  60239. * Defines the name of the task
  60240. */
  60241. name: string;
  60242. /**
  60243. * Defines the location of the file to load
  60244. */
  60245. url: string;
  60246. /**
  60247. * Defines if mipmap should not be generated (default is false)
  60248. */
  60249. noMipmap?: boolean | undefined;
  60250. /**
  60251. * Defines if texture must be inverted on Y axis (default is false)
  60252. */
  60253. invertY?: boolean | undefined;
  60254. /**
  60255. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60256. */
  60257. samplingMode: number;
  60258. /**
  60259. * Gets the loaded texture
  60260. */
  60261. texture: Texture;
  60262. /**
  60263. * Callback called when the task is successful
  60264. */
  60265. onSuccess: (task: TextureAssetTask) => void;
  60266. /**
  60267. * Callback called when the task is successful
  60268. */
  60269. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60270. /**
  60271. * Creates a new TextureAssetTask object
  60272. * @param name defines the name of the task
  60273. * @param url defines the location of the file to load
  60274. * @param noMipmap defines if mipmap should not be generated (default is false)
  60275. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60276. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60277. */
  60278. constructor(
  60279. /**
  60280. * Defines the name of the task
  60281. */
  60282. name: string,
  60283. /**
  60284. * Defines the location of the file to load
  60285. */
  60286. url: string,
  60287. /**
  60288. * Defines if mipmap should not be generated (default is false)
  60289. */
  60290. noMipmap?: boolean | undefined,
  60291. /**
  60292. * Defines if texture must be inverted on Y axis (default is false)
  60293. */
  60294. invertY?: boolean | undefined,
  60295. /**
  60296. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60297. */
  60298. samplingMode?: number);
  60299. /**
  60300. * Execute the current task
  60301. * @param scene defines the scene where you want your assets to be loaded
  60302. * @param onSuccess is a callback called when the task is successfully executed
  60303. * @param onError is a callback called if an error occurs
  60304. */
  60305. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60306. }
  60307. /**
  60308. * Define a task used by AssetsManager to load cube textures
  60309. */
  60310. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60311. /**
  60312. * Defines the name of the task
  60313. */
  60314. name: string;
  60315. /**
  60316. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60317. */
  60318. url: string;
  60319. /**
  60320. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60321. */
  60322. extensions?: string[] | undefined;
  60323. /**
  60324. * Defines if mipmaps should not be generated (default is false)
  60325. */
  60326. noMipmap?: boolean | undefined;
  60327. /**
  60328. * Defines the explicit list of files (undefined by default)
  60329. */
  60330. files?: string[] | undefined;
  60331. /**
  60332. * Gets the loaded texture
  60333. */
  60334. texture: CubeTexture;
  60335. /**
  60336. * Callback called when the task is successful
  60337. */
  60338. onSuccess: (task: CubeTextureAssetTask) => void;
  60339. /**
  60340. * Callback called when the task is successful
  60341. */
  60342. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60343. /**
  60344. * Creates a new CubeTextureAssetTask
  60345. * @param name defines the name of the task
  60346. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60347. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60348. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60349. * @param files defines the explicit list of files (undefined by default)
  60350. */
  60351. constructor(
  60352. /**
  60353. * Defines the name of the task
  60354. */
  60355. name: string,
  60356. /**
  60357. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60358. */
  60359. url: string,
  60360. /**
  60361. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60362. */
  60363. extensions?: string[] | undefined,
  60364. /**
  60365. * Defines if mipmaps should not be generated (default is false)
  60366. */
  60367. noMipmap?: boolean | undefined,
  60368. /**
  60369. * Defines the explicit list of files (undefined by default)
  60370. */
  60371. files?: string[] | undefined);
  60372. /**
  60373. * Execute the current task
  60374. * @param scene defines the scene where you want your assets to be loaded
  60375. * @param onSuccess is a callback called when the task is successfully executed
  60376. * @param onError is a callback called if an error occurs
  60377. */
  60378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60379. }
  60380. /**
  60381. * Define a task used by AssetsManager to load HDR cube textures
  60382. */
  60383. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60384. /**
  60385. * Defines the name of the task
  60386. */
  60387. name: string;
  60388. /**
  60389. * Defines the location of the file to load
  60390. */
  60391. url: string;
  60392. /**
  60393. * Defines the desired size (the more it increases the longer the generation will be)
  60394. */
  60395. size: number;
  60396. /**
  60397. * Defines if mipmaps should not be generated (default is false)
  60398. */
  60399. noMipmap: boolean;
  60400. /**
  60401. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60402. */
  60403. generateHarmonics: boolean;
  60404. /**
  60405. * 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)
  60406. */
  60407. gammaSpace: boolean;
  60408. /**
  60409. * Internal Use Only
  60410. */
  60411. reserved: boolean;
  60412. /**
  60413. * Gets the loaded texture
  60414. */
  60415. texture: HDRCubeTexture;
  60416. /**
  60417. * Callback called when the task is successful
  60418. */
  60419. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60420. /**
  60421. * Callback called when the task is successful
  60422. */
  60423. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60424. /**
  60425. * Creates a new HDRCubeTextureAssetTask object
  60426. * @param name defines the name of the task
  60427. * @param url defines the location of the file to load
  60428. * @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.
  60429. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60430. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60431. * @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)
  60432. * @param reserved Internal use only
  60433. */
  60434. constructor(
  60435. /**
  60436. * Defines the name of the task
  60437. */
  60438. name: string,
  60439. /**
  60440. * Defines the location of the file to load
  60441. */
  60442. url: string,
  60443. /**
  60444. * Defines the desired size (the more it increases the longer the generation will be)
  60445. */
  60446. size: number,
  60447. /**
  60448. * Defines if mipmaps should not be generated (default is false)
  60449. */
  60450. noMipmap?: boolean,
  60451. /**
  60452. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60453. */
  60454. generateHarmonics?: boolean,
  60455. /**
  60456. * 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)
  60457. */
  60458. gammaSpace?: boolean,
  60459. /**
  60460. * Internal Use Only
  60461. */
  60462. reserved?: boolean);
  60463. /**
  60464. * Execute the current task
  60465. * @param scene defines the scene where you want your assets to be loaded
  60466. * @param onSuccess is a callback called when the task is successfully executed
  60467. * @param onError is a callback called if an error occurs
  60468. */
  60469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60470. }
  60471. /**
  60472. * Define a task used by AssetsManager to load Equirectangular cube textures
  60473. */
  60474. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60475. /**
  60476. * Defines the name of the task
  60477. */
  60478. name: string;
  60479. /**
  60480. * Defines the location of the file to load
  60481. */
  60482. url: string;
  60483. /**
  60484. * Defines the desired size (the more it increases the longer the generation will be)
  60485. */
  60486. size: number;
  60487. /**
  60488. * Defines if mipmaps should not be generated (default is false)
  60489. */
  60490. noMipmap: boolean;
  60491. /**
  60492. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60493. * but the standard material would require them in Gamma space) (default is true)
  60494. */
  60495. gammaSpace: boolean;
  60496. /**
  60497. * Gets the loaded texture
  60498. */
  60499. texture: EquiRectangularCubeTexture;
  60500. /**
  60501. * Callback called when the task is successful
  60502. */
  60503. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60504. /**
  60505. * Callback called when the task is successful
  60506. */
  60507. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60508. /**
  60509. * Creates a new EquiRectangularCubeTextureAssetTask object
  60510. * @param name defines the name of the task
  60511. * @param url defines the location of the file to load
  60512. * @param size defines the desired size (the more it increases the longer the generation will be)
  60513. * If the size is omitted this implies you are using a preprocessed cubemap.
  60514. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60515. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60516. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60517. * (default is true)
  60518. */
  60519. constructor(
  60520. /**
  60521. * Defines the name of the task
  60522. */
  60523. name: string,
  60524. /**
  60525. * Defines the location of the file to load
  60526. */
  60527. url: string,
  60528. /**
  60529. * Defines the desired size (the more it increases the longer the generation will be)
  60530. */
  60531. size: number,
  60532. /**
  60533. * Defines if mipmaps should not be generated (default is false)
  60534. */
  60535. noMipmap?: boolean,
  60536. /**
  60537. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60538. * but the standard material would require them in Gamma space) (default is true)
  60539. */
  60540. gammaSpace?: boolean);
  60541. /**
  60542. * Execute the current task
  60543. * @param scene defines the scene where you want your assets to be loaded
  60544. * @param onSuccess is a callback called when the task is successfully executed
  60545. * @param onError is a callback called if an error occurs
  60546. */
  60547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60548. }
  60549. /**
  60550. * This class can be used to easily import assets into a scene
  60551. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60552. */
  60553. export class AssetsManager {
  60554. private _scene;
  60555. private _isLoading;
  60556. protected _tasks: AbstractAssetTask[];
  60557. protected _waitingTasksCount: number;
  60558. protected _totalTasksCount: number;
  60559. /**
  60560. * Callback called when all tasks are processed
  60561. */
  60562. onFinish: (tasks: AbstractAssetTask[]) => void;
  60563. /**
  60564. * Callback called when a task is successful
  60565. */
  60566. onTaskSuccess: (task: AbstractAssetTask) => void;
  60567. /**
  60568. * Callback called when a task had an error
  60569. */
  60570. onTaskError: (task: AbstractAssetTask) => void;
  60571. /**
  60572. * Callback called when a task is done (whatever the result is)
  60573. */
  60574. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60575. /**
  60576. * Observable called when all tasks are processed
  60577. */
  60578. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60579. /**
  60580. * Observable called when a task had an error
  60581. */
  60582. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60583. /**
  60584. * Observable called when all tasks were executed
  60585. */
  60586. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60587. /**
  60588. * Observable called when a task is done (whatever the result is)
  60589. */
  60590. onProgressObservable: Observable<IAssetsProgressEvent>;
  60591. /**
  60592. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60594. */
  60595. useDefaultLoadingScreen: boolean;
  60596. /**
  60597. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  60598. * when all assets have been downloaded.
  60599. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  60600. */
  60601. autoHideLoadingUI: boolean;
  60602. /**
  60603. * Creates a new AssetsManager
  60604. * @param scene defines the scene to work on
  60605. */
  60606. constructor(scene: Scene);
  60607. /**
  60608. * Add a MeshAssetTask to the list of active tasks
  60609. * @param taskName defines the name of the new task
  60610. * @param meshesNames defines the name of meshes to load
  60611. * @param rootUrl defines the root url to use to locate files
  60612. * @param sceneFilename defines the filename of the scene file
  60613. * @returns a new MeshAssetTask object
  60614. */
  60615. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60616. /**
  60617. * Add a TextFileAssetTask to the list of active tasks
  60618. * @param taskName defines the name of the new task
  60619. * @param url defines the url of the file to load
  60620. * @returns a new TextFileAssetTask object
  60621. */
  60622. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60623. /**
  60624. * Add a BinaryFileAssetTask to the list of active tasks
  60625. * @param taskName defines the name of the new task
  60626. * @param url defines the url of the file to load
  60627. * @returns a new BinaryFileAssetTask object
  60628. */
  60629. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60630. /**
  60631. * Add a ImageAssetTask to the list of active tasks
  60632. * @param taskName defines the name of the new task
  60633. * @param url defines the url of the file to load
  60634. * @returns a new ImageAssetTask object
  60635. */
  60636. addImageTask(taskName: string, url: string): ImageAssetTask;
  60637. /**
  60638. * Add a TextureAssetTask to the list of active tasks
  60639. * @param taskName defines the name of the new task
  60640. * @param url defines the url of the file to load
  60641. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60642. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60643. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60644. * @returns a new TextureAssetTask object
  60645. */
  60646. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60647. /**
  60648. * Add a CubeTextureAssetTask to the list of active tasks
  60649. * @param taskName defines the name of the new task
  60650. * @param url defines the url of the file to load
  60651. * @param extensions defines the extension to use to load the cube map (can be null)
  60652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60653. * @param files defines the list of files to load (can be null)
  60654. * @returns a new CubeTextureAssetTask object
  60655. */
  60656. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60657. /**
  60658. *
  60659. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60660. * @param taskName defines the name of the new task
  60661. * @param url defines the url of the file to load
  60662. * @param size defines the size you want for the cubemap (can be null)
  60663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60664. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60665. * @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)
  60666. * @param reserved Internal use only
  60667. * @returns a new HDRCubeTextureAssetTask object
  60668. */
  60669. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60670. /**
  60671. *
  60672. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60673. * @param taskName defines the name of the new task
  60674. * @param url defines the url of the file to load
  60675. * @param size defines the size you want for the cubemap (can be null)
  60676. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60677. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60678. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60679. * @returns a new EquiRectangularCubeTextureAssetTask object
  60680. */
  60681. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60682. /**
  60683. * Remove a task from the assets manager.
  60684. * @param task the task to remove
  60685. */
  60686. removeTask(task: AbstractAssetTask): void;
  60687. private _decreaseWaitingTasksCount;
  60688. private _runTask;
  60689. /**
  60690. * Reset the AssetsManager and remove all tasks
  60691. * @return the current instance of the AssetsManager
  60692. */
  60693. reset(): AssetsManager;
  60694. /**
  60695. * Start the loading process
  60696. * @return the current instance of the AssetsManager
  60697. */
  60698. load(): AssetsManager;
  60699. /**
  60700. * Start the loading process as an async operation
  60701. * @return a promise returning the list of failed tasks
  60702. */
  60703. loadAsync(): Promise<void>;
  60704. }
  60705. }
  60706. declare module BABYLON {
  60707. /**
  60708. * Wrapper class for promise with external resolve and reject.
  60709. */
  60710. export class Deferred<T> {
  60711. /**
  60712. * The promise associated with this deferred object.
  60713. */
  60714. readonly promise: Promise<T>;
  60715. private _resolve;
  60716. private _reject;
  60717. /**
  60718. * The resolve method of the promise associated with this deferred object.
  60719. */
  60720. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60721. /**
  60722. * The reject method of the promise associated with this deferred object.
  60723. */
  60724. readonly reject: (reason?: any) => void;
  60725. /**
  60726. * Constructor for this deferred object.
  60727. */
  60728. constructor();
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /**
  60733. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60734. */
  60735. export class MeshExploder {
  60736. private _centerMesh;
  60737. private _meshes;
  60738. private _meshesOrigins;
  60739. private _toCenterVectors;
  60740. private _scaledDirection;
  60741. private _newPosition;
  60742. private _centerPosition;
  60743. /**
  60744. * Explodes meshes from a center mesh.
  60745. * @param meshes The meshes to explode.
  60746. * @param centerMesh The mesh to be center of explosion.
  60747. */
  60748. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60749. private _setCenterMesh;
  60750. /**
  60751. * Get class name
  60752. * @returns "MeshExploder"
  60753. */
  60754. getClassName(): string;
  60755. /**
  60756. * "Exploded meshes"
  60757. * @returns Array of meshes with the centerMesh at index 0.
  60758. */
  60759. getMeshes(): Array<Mesh>;
  60760. /**
  60761. * Explodes meshes giving a specific direction
  60762. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60763. */
  60764. explode(direction?: number): void;
  60765. }
  60766. }
  60767. declare module BABYLON {
  60768. /**
  60769. * Class used to help managing file picking and drag'n'drop
  60770. */
  60771. export class FilesInput {
  60772. /**
  60773. * List of files ready to be loaded
  60774. */
  60775. static readonly FilesToLoad: {
  60776. [key: string]: File;
  60777. };
  60778. /**
  60779. * Callback called when a file is processed
  60780. */
  60781. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60782. private _engine;
  60783. private _currentScene;
  60784. private _sceneLoadedCallback;
  60785. private _progressCallback;
  60786. private _additionalRenderLoopLogicCallback;
  60787. private _textureLoadingCallback;
  60788. private _startingProcessingFilesCallback;
  60789. private _onReloadCallback;
  60790. private _errorCallback;
  60791. private _elementToMonitor;
  60792. private _sceneFileToLoad;
  60793. private _filesToLoad;
  60794. /**
  60795. * Creates a new FilesInput
  60796. * @param engine defines the rendering engine
  60797. * @param scene defines the hosting scene
  60798. * @param sceneLoadedCallback callback called when scene is loaded
  60799. * @param progressCallback callback called to track progress
  60800. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60801. * @param textureLoadingCallback callback called when a texture is loading
  60802. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60803. * @param onReloadCallback callback called when a reload is requested
  60804. * @param errorCallback callback call if an error occurs
  60805. */
  60806. 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);
  60807. private _dragEnterHandler;
  60808. private _dragOverHandler;
  60809. private _dropHandler;
  60810. /**
  60811. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60812. * @param elementToMonitor defines the DOM element to track
  60813. */
  60814. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60815. /**
  60816. * Release all associated resources
  60817. */
  60818. dispose(): void;
  60819. private renderFunction;
  60820. private drag;
  60821. private drop;
  60822. private _traverseFolder;
  60823. private _processFiles;
  60824. /**
  60825. * Load files from a drop event
  60826. * @param event defines the drop event to use as source
  60827. */
  60828. loadFiles(event: any): void;
  60829. private _processReload;
  60830. /**
  60831. * Reload the current scene from the loaded files
  60832. */
  60833. reload(): void;
  60834. }
  60835. }
  60836. declare module BABYLON {
  60837. /**
  60838. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60840. */
  60841. export class SceneOptimization {
  60842. /**
  60843. * Defines the priority of this optimization (0 by default which means first in the list)
  60844. */
  60845. priority: number;
  60846. /**
  60847. * Gets a string describing the action executed by the current optimization
  60848. * @returns description string
  60849. */
  60850. getDescription(): string;
  60851. /**
  60852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60853. * @param scene defines the current scene where to apply this optimization
  60854. * @param optimizer defines the current optimizer
  60855. * @returns true if everything that can be done was applied
  60856. */
  60857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60858. /**
  60859. * Creates the SceneOptimization object
  60860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60861. * @param desc defines the description associated with the optimization
  60862. */
  60863. constructor(
  60864. /**
  60865. * Defines the priority of this optimization (0 by default which means first in the list)
  60866. */
  60867. priority?: number);
  60868. }
  60869. /**
  60870. * Defines an optimization used to reduce the size of render target textures
  60871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60872. */
  60873. export class TextureOptimization extends SceneOptimization {
  60874. /**
  60875. * Defines the priority of this optimization (0 by default which means first in the list)
  60876. */
  60877. priority: number;
  60878. /**
  60879. * 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
  60880. */
  60881. maximumSize: number;
  60882. /**
  60883. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60884. */
  60885. step: number;
  60886. /**
  60887. * Gets a string describing the action executed by the current optimization
  60888. * @returns description string
  60889. */
  60890. getDescription(): string;
  60891. /**
  60892. * Creates the TextureOptimization object
  60893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60894. * @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
  60895. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60896. */
  60897. constructor(
  60898. /**
  60899. * Defines the priority of this optimization (0 by default which means first in the list)
  60900. */
  60901. priority?: number,
  60902. /**
  60903. * 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
  60904. */
  60905. maximumSize?: number,
  60906. /**
  60907. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60908. */
  60909. step?: number);
  60910. /**
  60911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60912. * @param scene defines the current scene where to apply this optimization
  60913. * @param optimizer defines the current optimizer
  60914. * @returns true if everything that can be done was applied
  60915. */
  60916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60917. }
  60918. /**
  60919. * Defines an optimization used to increase or decrease the rendering resolution
  60920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60921. */
  60922. export class HardwareScalingOptimization extends SceneOptimization {
  60923. /**
  60924. * Defines the priority of this optimization (0 by default which means first in the list)
  60925. */
  60926. priority: number;
  60927. /**
  60928. * Defines the maximum scale to use (2 by default)
  60929. */
  60930. maximumScale: number;
  60931. /**
  60932. * Defines the step to use between two passes (0.5 by default)
  60933. */
  60934. step: number;
  60935. private _currentScale;
  60936. private _directionOffset;
  60937. /**
  60938. * Gets a string describing the action executed by the current optimization
  60939. * @return description string
  60940. */
  60941. getDescription(): string;
  60942. /**
  60943. * Creates the HardwareScalingOptimization object
  60944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60945. * @param maximumScale defines the maximum scale to use (2 by default)
  60946. * @param step defines the step to use between two passes (0.5 by default)
  60947. */
  60948. constructor(
  60949. /**
  60950. * Defines the priority of this optimization (0 by default which means first in the list)
  60951. */
  60952. priority?: number,
  60953. /**
  60954. * Defines the maximum scale to use (2 by default)
  60955. */
  60956. maximumScale?: number,
  60957. /**
  60958. * Defines the step to use between two passes (0.5 by default)
  60959. */
  60960. step?: number);
  60961. /**
  60962. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60963. * @param scene defines the current scene where to apply this optimization
  60964. * @param optimizer defines the current optimizer
  60965. * @returns true if everything that can be done was applied
  60966. */
  60967. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60968. }
  60969. /**
  60970. * Defines an optimization used to remove shadows
  60971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60972. */
  60973. export class ShadowsOptimization extends SceneOptimization {
  60974. /**
  60975. * Gets a string describing the action executed by the current optimization
  60976. * @return description string
  60977. */
  60978. getDescription(): string;
  60979. /**
  60980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60981. * @param scene defines the current scene where to apply this optimization
  60982. * @param optimizer defines the current optimizer
  60983. * @returns true if everything that can be done was applied
  60984. */
  60985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60986. }
  60987. /**
  60988. * Defines an optimization used to turn post-processes off
  60989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60990. */
  60991. export class PostProcessesOptimization extends SceneOptimization {
  60992. /**
  60993. * Gets a string describing the action executed by the current optimization
  60994. * @return description string
  60995. */
  60996. getDescription(): string;
  60997. /**
  60998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60999. * @param scene defines the current scene where to apply this optimization
  61000. * @param optimizer defines the current optimizer
  61001. * @returns true if everything that can be done was applied
  61002. */
  61003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61004. }
  61005. /**
  61006. * Defines an optimization used to turn lens flares off
  61007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61008. */
  61009. export class LensFlaresOptimization extends SceneOptimization {
  61010. /**
  61011. * Gets a string describing the action executed by the current optimization
  61012. * @return description string
  61013. */
  61014. getDescription(): string;
  61015. /**
  61016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61017. * @param scene defines the current scene where to apply this optimization
  61018. * @param optimizer defines the current optimizer
  61019. * @returns true if everything that can be done was applied
  61020. */
  61021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61022. }
  61023. /**
  61024. * Defines an optimization based on user defined callback.
  61025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61026. */
  61027. export class CustomOptimization extends SceneOptimization {
  61028. /**
  61029. * Callback called to apply the custom optimization.
  61030. */
  61031. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61032. /**
  61033. * Callback called to get custom description
  61034. */
  61035. onGetDescription: () => string;
  61036. /**
  61037. * Gets a string describing the action executed by the current optimization
  61038. * @returns description string
  61039. */
  61040. getDescription(): string;
  61041. /**
  61042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61043. * @param scene defines the current scene where to apply this optimization
  61044. * @param optimizer defines the current optimizer
  61045. * @returns true if everything that can be done was applied
  61046. */
  61047. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61048. }
  61049. /**
  61050. * Defines an optimization used to turn particles off
  61051. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61052. */
  61053. export class ParticlesOptimization extends SceneOptimization {
  61054. /**
  61055. * Gets a string describing the action executed by the current optimization
  61056. * @return description string
  61057. */
  61058. getDescription(): string;
  61059. /**
  61060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61061. * @param scene defines the current scene where to apply this optimization
  61062. * @param optimizer defines the current optimizer
  61063. * @returns true if everything that can be done was applied
  61064. */
  61065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61066. }
  61067. /**
  61068. * Defines an optimization used to turn render targets off
  61069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61070. */
  61071. export class RenderTargetsOptimization extends SceneOptimization {
  61072. /**
  61073. * Gets a string describing the action executed by the current optimization
  61074. * @return description string
  61075. */
  61076. getDescription(): string;
  61077. /**
  61078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61079. * @param scene defines the current scene where to apply this optimization
  61080. * @param optimizer defines the current optimizer
  61081. * @returns true if everything that can be done was applied
  61082. */
  61083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61084. }
  61085. /**
  61086. * Defines an optimization used to merge meshes with compatible materials
  61087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61088. */
  61089. export class MergeMeshesOptimization extends SceneOptimization {
  61090. private static _UpdateSelectionTree;
  61091. /**
  61092. * Gets or sets a boolean which defines if optimization octree has to be updated
  61093. */
  61094. /**
  61095. * Gets or sets a boolean which defines if optimization octree has to be updated
  61096. */
  61097. static UpdateSelectionTree: boolean;
  61098. /**
  61099. * Gets a string describing the action executed by the current optimization
  61100. * @return description string
  61101. */
  61102. getDescription(): string;
  61103. private _canBeMerged;
  61104. /**
  61105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61106. * @param scene defines the current scene where to apply this optimization
  61107. * @param optimizer defines the current optimizer
  61108. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61109. * @returns true if everything that can be done was applied
  61110. */
  61111. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61112. }
  61113. /**
  61114. * Defines a list of options used by SceneOptimizer
  61115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61116. */
  61117. export class SceneOptimizerOptions {
  61118. /**
  61119. * Defines the target frame rate to reach (60 by default)
  61120. */
  61121. targetFrameRate: number;
  61122. /**
  61123. * Defines the interval between two checkes (2000ms by default)
  61124. */
  61125. trackerDuration: number;
  61126. /**
  61127. * Gets the list of optimizations to apply
  61128. */
  61129. optimizations: SceneOptimization[];
  61130. /**
  61131. * Creates a new list of options used by SceneOptimizer
  61132. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61133. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61134. */
  61135. constructor(
  61136. /**
  61137. * Defines the target frame rate to reach (60 by default)
  61138. */
  61139. targetFrameRate?: number,
  61140. /**
  61141. * Defines the interval between two checkes (2000ms by default)
  61142. */
  61143. trackerDuration?: number);
  61144. /**
  61145. * Add a new optimization
  61146. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61147. * @returns the current SceneOptimizerOptions
  61148. */
  61149. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61150. /**
  61151. * Add a new custom optimization
  61152. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61153. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61155. * @returns the current SceneOptimizerOptions
  61156. */
  61157. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61158. /**
  61159. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61160. * @param targetFrameRate defines the target frame rate (60 by default)
  61161. * @returns a SceneOptimizerOptions object
  61162. */
  61163. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61164. /**
  61165. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61166. * @param targetFrameRate defines the target frame rate (60 by default)
  61167. * @returns a SceneOptimizerOptions object
  61168. */
  61169. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61170. /**
  61171. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61172. * @param targetFrameRate defines the target frame rate (60 by default)
  61173. * @returns a SceneOptimizerOptions object
  61174. */
  61175. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61176. }
  61177. /**
  61178. * Class used to run optimizations in order to reach a target frame rate
  61179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61180. */
  61181. export class SceneOptimizer implements IDisposable {
  61182. private _isRunning;
  61183. private _options;
  61184. private _scene;
  61185. private _currentPriorityLevel;
  61186. private _targetFrameRate;
  61187. private _trackerDuration;
  61188. private _currentFrameRate;
  61189. private _sceneDisposeObserver;
  61190. private _improvementMode;
  61191. /**
  61192. * Defines an observable called when the optimizer reaches the target frame rate
  61193. */
  61194. onSuccessObservable: Observable<SceneOptimizer>;
  61195. /**
  61196. * Defines an observable called when the optimizer enables an optimization
  61197. */
  61198. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61199. /**
  61200. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61201. */
  61202. onFailureObservable: Observable<SceneOptimizer>;
  61203. /**
  61204. * Gets a boolean indicating if the optimizer is in improvement mode
  61205. */
  61206. readonly isInImprovementMode: boolean;
  61207. /**
  61208. * Gets the current priority level (0 at start)
  61209. */
  61210. readonly currentPriorityLevel: number;
  61211. /**
  61212. * Gets the current frame rate checked by the SceneOptimizer
  61213. */
  61214. readonly currentFrameRate: number;
  61215. /**
  61216. * Gets or sets the current target frame rate (60 by default)
  61217. */
  61218. /**
  61219. * Gets or sets the current target frame rate (60 by default)
  61220. */
  61221. targetFrameRate: number;
  61222. /**
  61223. * Gets or sets the current interval between two checks (every 2000ms by default)
  61224. */
  61225. /**
  61226. * Gets or sets the current interval between two checks (every 2000ms by default)
  61227. */
  61228. trackerDuration: number;
  61229. /**
  61230. * Gets the list of active optimizations
  61231. */
  61232. readonly optimizations: SceneOptimization[];
  61233. /**
  61234. * Creates a new SceneOptimizer
  61235. * @param scene defines the scene to work on
  61236. * @param options defines the options to use with the SceneOptimizer
  61237. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61238. * @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)
  61239. */
  61240. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61241. /**
  61242. * Stops the current optimizer
  61243. */
  61244. stop(): void;
  61245. /**
  61246. * Reset the optimizer to initial step (current priority level = 0)
  61247. */
  61248. reset(): void;
  61249. /**
  61250. * Start the optimizer. By default it will try to reach a specific framerate
  61251. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61252. */
  61253. start(): void;
  61254. private _checkCurrentState;
  61255. /**
  61256. * Release all resources
  61257. */
  61258. dispose(): void;
  61259. /**
  61260. * Helper function to create a SceneOptimizer with one single line of code
  61261. * @param scene defines the scene to work on
  61262. * @param options defines the options to use with the SceneOptimizer
  61263. * @param onSuccess defines a callback to call on success
  61264. * @param onFailure defines a callback to call on failure
  61265. * @returns the new SceneOptimizer object
  61266. */
  61267. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61268. }
  61269. }
  61270. declare module BABYLON {
  61271. /**
  61272. * Class used to serialize a scene into a string
  61273. */
  61274. export class SceneSerializer {
  61275. /**
  61276. * Clear cache used by a previous serialization
  61277. */
  61278. static ClearCache(): void;
  61279. /**
  61280. * Serialize a scene into a JSON compatible object
  61281. * @param scene defines the scene to serialize
  61282. * @returns a JSON compatible object
  61283. */
  61284. static Serialize(scene: Scene): any;
  61285. /**
  61286. * Serialize a mesh into a JSON compatible object
  61287. * @param toSerialize defines the mesh to serialize
  61288. * @param withParents defines if parents must be serialized as well
  61289. * @param withChildren defines if children must be serialized as well
  61290. * @returns a JSON compatible object
  61291. */
  61292. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61293. }
  61294. }
  61295. declare module BABYLON {
  61296. /**
  61297. * Class used to host texture specific utilities
  61298. */
  61299. export class TextureTools {
  61300. /**
  61301. * Uses the GPU to create a copy texture rescaled at a given size
  61302. * @param texture Texture to copy from
  61303. * @param width defines the desired width
  61304. * @param height defines the desired height
  61305. * @param useBilinearMode defines if bilinear mode has to be used
  61306. * @return the generated texture
  61307. */
  61308. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61309. }
  61310. }
  61311. declare module BABYLON {
  61312. /**
  61313. * This represents the different options available for the video capture.
  61314. */
  61315. export interface VideoRecorderOptions {
  61316. /** Defines the mime type of the video. */
  61317. mimeType: string;
  61318. /** Defines the FPS the video should be recorded at. */
  61319. fps: number;
  61320. /** Defines the chunk size for the recording data. */
  61321. recordChunckSize: number;
  61322. /** The audio tracks to attach to the recording. */
  61323. audioTracks?: MediaStreamTrack[];
  61324. }
  61325. /**
  61326. * This can help with recording videos from BabylonJS.
  61327. * This is based on the available WebRTC functionalities of the browser.
  61328. *
  61329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61330. */
  61331. export class VideoRecorder {
  61332. private static readonly _defaultOptions;
  61333. /**
  61334. * Returns whether or not the VideoRecorder is available in your browser.
  61335. * @param engine Defines the Babylon Engine.
  61336. * @returns true if supported otherwise false.
  61337. */
  61338. static IsSupported(engine: Engine): boolean;
  61339. private readonly _options;
  61340. private _canvas;
  61341. private _mediaRecorder;
  61342. private _recordedChunks;
  61343. private _fileName;
  61344. private _resolve;
  61345. private _reject;
  61346. /**
  61347. * True when a recording is already in progress.
  61348. */
  61349. readonly isRecording: boolean;
  61350. /**
  61351. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61352. * @param engine Defines the BabylonJS Engine you wish to record.
  61353. * @param options Defines options that can be used to customize the capture.
  61354. */
  61355. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61356. /**
  61357. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61358. */
  61359. stopRecording(): void;
  61360. /**
  61361. * Starts recording the canvas for a max duration specified in parameters.
  61362. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61363. * If null no automatic download will start and you can rely on the promise to get the data back.
  61364. * @param maxDuration Defines the maximum recording time in seconds.
  61365. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61366. * @return A promise callback at the end of the recording with the video data in Blob.
  61367. */
  61368. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61369. /**
  61370. * Releases internal resources used during the recording.
  61371. */
  61372. dispose(): void;
  61373. private _handleDataAvailable;
  61374. private _handleError;
  61375. private _handleStop;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Class containing a set of static utilities functions for screenshots
  61381. */
  61382. export class ScreenshotTools {
  61383. /**
  61384. * Captures a screenshot of the current rendering
  61385. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61386. * @param engine defines the rendering engine
  61387. * @param camera defines the source camera
  61388. * @param size This parameter can be set to a single number or to an object with the
  61389. * following (optional) properties: precision, width, height. If a single number is passed,
  61390. * it will be used for both width and height. If an object is passed, the screenshot size
  61391. * will be derived from the parameters. The precision property is a multiplier allowing
  61392. * rendering at a higher or lower resolution
  61393. * @param successCallback defines the callback receives a single parameter which contains the
  61394. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61395. * src parameter of an <img> to display it
  61396. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61397. * Check your browser for supported MIME types
  61398. */
  61399. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  61400. /**
  61401. * Captures a screenshot of the current rendering
  61402. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61403. * @param engine defines the rendering engine
  61404. * @param camera defines the source camera
  61405. * @param size This parameter can be set to a single number or to an object with the
  61406. * following (optional) properties: precision, width, height. If a single number is passed,
  61407. * it will be used for both width and height. If an object is passed, the screenshot size
  61408. * will be derived from the parameters. The precision property is a multiplier allowing
  61409. * rendering at a higher or lower resolution
  61410. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61411. * Check your browser for supported MIME types
  61412. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61413. * to the src parameter of an <img> to display it
  61414. */
  61415. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  61416. /**
  61417. * Generates an image screenshot from the specified camera.
  61418. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61419. * @param engine The engine to use for rendering
  61420. * @param camera The camera to use for rendering
  61421. * @param size This parameter can be set to a single number or to an object with the
  61422. * following (optional) properties: precision, width, height. If a single number is passed,
  61423. * it will be used for both width and height. If an object is passed, the screenshot size
  61424. * will be derived from the parameters. The precision property is a multiplier allowing
  61425. * rendering at a higher or lower resolution
  61426. * @param successCallback The callback receives a single parameter which contains the
  61427. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61428. * src parameter of an <img> to display it
  61429. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61430. * Check your browser for supported MIME types
  61431. * @param samples Texture samples (default: 1)
  61432. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61433. * @param fileName A name for for the downloaded file.
  61434. */
  61435. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61436. /**
  61437. * Generates an image screenshot from the specified camera.
  61438. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61439. * @param engine The engine to use for rendering
  61440. * @param camera The camera to use for rendering
  61441. * @param size This parameter can be set to a single number or to an object with the
  61442. * following (optional) properties: precision, width, height. If a single number is passed,
  61443. * it will be used for both width and height. If an object is passed, the screenshot size
  61444. * will be derived from the parameters. The precision property is a multiplier allowing
  61445. * rendering at a higher or lower resolution
  61446. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61447. * Check your browser for supported MIME types
  61448. * @param samples Texture samples (default: 1)
  61449. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61450. * @param fileName A name for for the downloaded file.
  61451. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  61452. * to the src parameter of an <img> to display it
  61453. */
  61454. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  61455. /**
  61456. * Gets height and width for screenshot size
  61457. * @private
  61458. */
  61459. private static _getScreenshotSize;
  61460. }
  61461. }
  61462. declare module BABYLON {
  61463. /**
  61464. * A cursor which tracks a point on a path
  61465. */
  61466. export class PathCursor {
  61467. private path;
  61468. /**
  61469. * Stores path cursor callbacks for when an onchange event is triggered
  61470. */
  61471. private _onchange;
  61472. /**
  61473. * The value of the path cursor
  61474. */
  61475. value: number;
  61476. /**
  61477. * The animation array of the path cursor
  61478. */
  61479. animations: Animation[];
  61480. /**
  61481. * Initializes the path cursor
  61482. * @param path The path to track
  61483. */
  61484. constructor(path: Path2);
  61485. /**
  61486. * Gets the cursor point on the path
  61487. * @returns A point on the path cursor at the cursor location
  61488. */
  61489. getPoint(): Vector3;
  61490. /**
  61491. * Moves the cursor ahead by the step amount
  61492. * @param step The amount to move the cursor forward
  61493. * @returns This path cursor
  61494. */
  61495. moveAhead(step?: number): PathCursor;
  61496. /**
  61497. * Moves the cursor behind by the step amount
  61498. * @param step The amount to move the cursor back
  61499. * @returns This path cursor
  61500. */
  61501. moveBack(step?: number): PathCursor;
  61502. /**
  61503. * Moves the cursor by the step amount
  61504. * If the step amount is greater than one, an exception is thrown
  61505. * @param step The amount to move the cursor
  61506. * @returns This path cursor
  61507. */
  61508. move(step: number): PathCursor;
  61509. /**
  61510. * Ensures that the value is limited between zero and one
  61511. * @returns This path cursor
  61512. */
  61513. private ensureLimits;
  61514. /**
  61515. * Runs onchange callbacks on change (used by the animation engine)
  61516. * @returns This path cursor
  61517. */
  61518. private raiseOnChange;
  61519. /**
  61520. * Executes a function on change
  61521. * @param f A path cursor onchange callback
  61522. * @returns This path cursor
  61523. */
  61524. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61525. }
  61526. }
  61527. declare module BABYLON {
  61528. /** @hidden */
  61529. export var blurPixelShader: {
  61530. name: string;
  61531. shader: string;
  61532. };
  61533. }
  61534. declare module BABYLON {
  61535. /** @hidden */
  61536. export var pointCloudVertexDeclaration: {
  61537. name: string;
  61538. shader: string;
  61539. };
  61540. }
  61541. // Mixins
  61542. interface Window {
  61543. mozIndexedDB: IDBFactory;
  61544. webkitIndexedDB: IDBFactory;
  61545. msIndexedDB: IDBFactory;
  61546. webkitURL: typeof URL;
  61547. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61548. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61549. WebGLRenderingContext: WebGLRenderingContext;
  61550. MSGesture: MSGesture;
  61551. CANNON: any;
  61552. AudioContext: AudioContext;
  61553. webkitAudioContext: AudioContext;
  61554. PointerEvent: any;
  61555. Math: Math;
  61556. Uint8Array: Uint8ArrayConstructor;
  61557. Float32Array: Float32ArrayConstructor;
  61558. mozURL: typeof URL;
  61559. msURL: typeof URL;
  61560. VRFrameData: any; // WebVR, from specs 1.1
  61561. DracoDecoderModule: any;
  61562. setImmediate(handler: (...args: any[]) => void): number;
  61563. }
  61564. interface HTMLCanvasElement {
  61565. requestPointerLock(): void;
  61566. msRequestPointerLock?(): void;
  61567. mozRequestPointerLock?(): void;
  61568. webkitRequestPointerLock?(): void;
  61569. /** Track wether a record is in progress */
  61570. isRecording: boolean;
  61571. /** Capture Stream method defined by some browsers */
  61572. captureStream(fps?: number): MediaStream;
  61573. }
  61574. interface CanvasRenderingContext2D {
  61575. msImageSmoothingEnabled: boolean;
  61576. }
  61577. interface MouseEvent {
  61578. mozMovementX: number;
  61579. mozMovementY: number;
  61580. webkitMovementX: number;
  61581. webkitMovementY: number;
  61582. msMovementX: number;
  61583. msMovementY: number;
  61584. }
  61585. interface Navigator {
  61586. mozGetVRDevices: (any: any) => any;
  61587. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61588. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61589. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61590. webkitGetGamepads(): Gamepad[];
  61591. msGetGamepads(): Gamepad[];
  61592. webkitGamepads(): Gamepad[];
  61593. }
  61594. interface HTMLVideoElement {
  61595. mozSrcObject: any;
  61596. }
  61597. interface Math {
  61598. fround(x: number): number;
  61599. imul(a: number, b: number): number;
  61600. }
  61601. interface WebGLRenderingContext {
  61602. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61603. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61604. vertexAttribDivisor(index: number, divisor: number): void;
  61605. createVertexArray(): any;
  61606. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61607. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61608. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61609. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61610. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61611. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61612. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61613. // Queries
  61614. createQuery(): WebGLQuery;
  61615. deleteQuery(query: WebGLQuery): void;
  61616. beginQuery(target: number, query: WebGLQuery): void;
  61617. endQuery(target: number): void;
  61618. getQueryParameter(query: WebGLQuery, pname: number): any;
  61619. getQuery(target: number, pname: number): any;
  61620. MAX_SAMPLES: number;
  61621. RGBA8: number;
  61622. READ_FRAMEBUFFER: number;
  61623. DRAW_FRAMEBUFFER: number;
  61624. UNIFORM_BUFFER: number;
  61625. HALF_FLOAT_OES: number;
  61626. RGBA16F: number;
  61627. RGBA32F: number;
  61628. R32F: number;
  61629. RG32F: number;
  61630. RGB32F: number;
  61631. R16F: number;
  61632. RG16F: number;
  61633. RGB16F: number;
  61634. RED: number;
  61635. RG: number;
  61636. R8: number;
  61637. RG8: number;
  61638. UNSIGNED_INT_24_8: number;
  61639. DEPTH24_STENCIL8: number;
  61640. /* Multiple Render Targets */
  61641. drawBuffers(buffers: number[]): void;
  61642. readBuffer(src: number): void;
  61643. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61644. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61645. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61646. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61647. // Occlusion Query
  61648. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61649. ANY_SAMPLES_PASSED: number;
  61650. QUERY_RESULT_AVAILABLE: number;
  61651. QUERY_RESULT: number;
  61652. }
  61653. interface WebGLProgram {
  61654. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61655. }
  61656. interface EXT_disjoint_timer_query {
  61657. QUERY_COUNTER_BITS_EXT: number;
  61658. TIME_ELAPSED_EXT: number;
  61659. TIMESTAMP_EXT: number;
  61660. GPU_DISJOINT_EXT: number;
  61661. QUERY_RESULT_EXT: number;
  61662. QUERY_RESULT_AVAILABLE_EXT: number;
  61663. queryCounterEXT(query: WebGLQuery, target: number): void;
  61664. createQueryEXT(): WebGLQuery;
  61665. beginQueryEXT(target: number, query: WebGLQuery): void;
  61666. endQueryEXT(target: number): void;
  61667. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61668. deleteQueryEXT(query: WebGLQuery): void;
  61669. }
  61670. interface WebGLUniformLocation {
  61671. _currentState: any;
  61672. }
  61673. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61674. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61675. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61676. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61677. interface WebGLRenderingContext {
  61678. readonly RASTERIZER_DISCARD: number;
  61679. readonly DEPTH_COMPONENT24: number;
  61680. readonly TEXTURE_3D: number;
  61681. readonly TEXTURE_2D_ARRAY: number;
  61682. readonly TEXTURE_COMPARE_FUNC: number;
  61683. readonly TEXTURE_COMPARE_MODE: number;
  61684. readonly COMPARE_REF_TO_TEXTURE: number;
  61685. readonly TEXTURE_WRAP_R: number;
  61686. readonly HALF_FLOAT: number;
  61687. readonly RGB8: number;
  61688. readonly RED_INTEGER: number;
  61689. readonly RG_INTEGER: number;
  61690. readonly RGB_INTEGER: number;
  61691. readonly RGBA_INTEGER: number;
  61692. readonly R8_SNORM: number;
  61693. readonly RG8_SNORM: number;
  61694. readonly RGB8_SNORM: number;
  61695. readonly RGBA8_SNORM: number;
  61696. readonly R8I: number;
  61697. readonly RG8I: number;
  61698. readonly RGB8I: number;
  61699. readonly RGBA8I: number;
  61700. readonly R8UI: number;
  61701. readonly RG8UI: number;
  61702. readonly RGB8UI: number;
  61703. readonly RGBA8UI: number;
  61704. readonly R16I: number;
  61705. readonly RG16I: number;
  61706. readonly RGB16I: number;
  61707. readonly RGBA16I: number;
  61708. readonly R16UI: number;
  61709. readonly RG16UI: number;
  61710. readonly RGB16UI: number;
  61711. readonly RGBA16UI: number;
  61712. readonly R32I: number;
  61713. readonly RG32I: number;
  61714. readonly RGB32I: number;
  61715. readonly RGBA32I: number;
  61716. readonly R32UI: number;
  61717. readonly RG32UI: number;
  61718. readonly RGB32UI: number;
  61719. readonly RGBA32UI: number;
  61720. readonly RGB10_A2UI: number;
  61721. readonly R11F_G11F_B10F: number;
  61722. readonly RGB9_E5: number;
  61723. readonly RGB10_A2: number;
  61724. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61725. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61726. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61727. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61728. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61729. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61730. 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;
  61731. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61732. readonly TRANSFORM_FEEDBACK: number;
  61733. readonly INTERLEAVED_ATTRIBS: number;
  61734. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61735. createTransformFeedback(): WebGLTransformFeedback;
  61736. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61737. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61738. beginTransformFeedback(primitiveMode: number): void;
  61739. endTransformFeedback(): void;
  61740. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61741. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61742. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61743. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61744. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61745. }
  61746. interface ImageBitmap {
  61747. readonly width: number;
  61748. readonly height: number;
  61749. close(): void;
  61750. }
  61751. interface WebGLQuery extends WebGLObject {
  61752. }
  61753. declare var WebGLQuery: {
  61754. prototype: WebGLQuery;
  61755. new(): WebGLQuery;
  61756. };
  61757. interface WebGLSampler extends WebGLObject {
  61758. }
  61759. declare var WebGLSampler: {
  61760. prototype: WebGLSampler;
  61761. new(): WebGLSampler;
  61762. };
  61763. interface WebGLSync extends WebGLObject {
  61764. }
  61765. declare var WebGLSync: {
  61766. prototype: WebGLSync;
  61767. new(): WebGLSync;
  61768. };
  61769. interface WebGLTransformFeedback extends WebGLObject {
  61770. }
  61771. declare var WebGLTransformFeedback: {
  61772. prototype: WebGLTransformFeedback;
  61773. new(): WebGLTransformFeedback;
  61774. };
  61775. interface WebGLVertexArrayObject extends WebGLObject {
  61776. }
  61777. declare var WebGLVertexArrayObject: {
  61778. prototype: WebGLVertexArrayObject;
  61779. new(): WebGLVertexArrayObject;
  61780. };
  61781. // Type definitions for WebVR API
  61782. // Project: https://w3c.github.io/webvr/
  61783. // Definitions by: six a <https://github.com/lostfictions>
  61784. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61785. interface VRDisplay extends EventTarget {
  61786. /**
  61787. * Dictionary of capabilities describing the VRDisplay.
  61788. */
  61789. readonly capabilities: VRDisplayCapabilities;
  61790. /**
  61791. * z-depth defining the far plane of the eye view frustum
  61792. * enables mapping of values in the render target depth
  61793. * attachment to scene coordinates. Initially set to 10000.0.
  61794. */
  61795. depthFar: number;
  61796. /**
  61797. * z-depth defining the near plane of the eye view frustum
  61798. * enables mapping of values in the render target depth
  61799. * attachment to scene coordinates. Initially set to 0.01.
  61800. */
  61801. depthNear: number;
  61802. /**
  61803. * An identifier for this distinct VRDisplay. Used as an
  61804. * association point in the Gamepad API.
  61805. */
  61806. readonly displayId: number;
  61807. /**
  61808. * A display name, a user-readable name identifying it.
  61809. */
  61810. readonly displayName: string;
  61811. readonly isConnected: boolean;
  61812. readonly isPresenting: boolean;
  61813. /**
  61814. * If this VRDisplay supports room-scale experiences, the optional
  61815. * stage attribute contains details on the room-scale parameters.
  61816. */
  61817. readonly stageParameters: VRStageParameters | null;
  61818. /**
  61819. * Passing the value returned by `requestAnimationFrame` to
  61820. * `cancelAnimationFrame` will unregister the callback.
  61821. * @param handle Define the hanle of the request to cancel
  61822. */
  61823. cancelAnimationFrame(handle: number): void;
  61824. /**
  61825. * Stops presenting to the VRDisplay.
  61826. * @returns a promise to know when it stopped
  61827. */
  61828. exitPresent(): Promise<void>;
  61829. /**
  61830. * Return the current VREyeParameters for the given eye.
  61831. * @param whichEye Define the eye we want the parameter for
  61832. * @returns the eye parameters
  61833. */
  61834. getEyeParameters(whichEye: string): VREyeParameters;
  61835. /**
  61836. * Populates the passed VRFrameData with the information required to render
  61837. * the current frame.
  61838. * @param frameData Define the data structure to populate
  61839. * @returns true if ok otherwise false
  61840. */
  61841. getFrameData(frameData: VRFrameData): boolean;
  61842. /**
  61843. * Get the layers currently being presented.
  61844. * @returns the list of VR layers
  61845. */
  61846. getLayers(): VRLayer[];
  61847. /**
  61848. * Return a VRPose containing the future predicted pose of the VRDisplay
  61849. * when the current frame will be presented. The value returned will not
  61850. * change until JavaScript has returned control to the browser.
  61851. *
  61852. * The VRPose will contain the position, orientation, velocity,
  61853. * and acceleration of each of these properties.
  61854. * @returns the pose object
  61855. */
  61856. getPose(): VRPose;
  61857. /**
  61858. * Return the current instantaneous pose of the VRDisplay, with no
  61859. * prediction applied.
  61860. * @returns the current instantaneous pose
  61861. */
  61862. getImmediatePose(): VRPose;
  61863. /**
  61864. * The callback passed to `requestAnimationFrame` will be called
  61865. * any time a new frame should be rendered. When the VRDisplay is
  61866. * presenting the callback will be called at the native refresh
  61867. * rate of the HMD. When not presenting this function acts
  61868. * identically to how window.requestAnimationFrame acts. Content should
  61869. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61870. * asynchronously from other displays and at differing refresh rates.
  61871. * @param callback Define the eaction to run next frame
  61872. * @returns the request handle it
  61873. */
  61874. requestAnimationFrame(callback: FrameRequestCallback): number;
  61875. /**
  61876. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61877. * Repeat calls while already presenting will update the VRLayers being displayed.
  61878. * @param layers Define the list of layer to present
  61879. * @returns a promise to know when the request has been fulfilled
  61880. */
  61881. requestPresent(layers: VRLayer[]): Promise<void>;
  61882. /**
  61883. * Reset the pose for this display, treating its current position and
  61884. * orientation as the "origin/zero" values. VRPose.position,
  61885. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61886. * updated when calling resetPose(). This should be called in only
  61887. * sitting-space experiences.
  61888. */
  61889. resetPose(): void;
  61890. /**
  61891. * The VRLayer provided to the VRDisplay will be captured and presented
  61892. * in the HMD. Calling this function has the same effect on the source
  61893. * canvas as any other operation that uses its source image, and canvases
  61894. * created without preserveDrawingBuffer set to true will be cleared.
  61895. * @param pose Define the pose to submit
  61896. */
  61897. submitFrame(pose?: VRPose): void;
  61898. }
  61899. declare var VRDisplay: {
  61900. prototype: VRDisplay;
  61901. new(): VRDisplay;
  61902. };
  61903. interface VRLayer {
  61904. leftBounds?: number[] | Float32Array | null;
  61905. rightBounds?: number[] | Float32Array | null;
  61906. source?: HTMLCanvasElement | null;
  61907. }
  61908. interface VRDisplayCapabilities {
  61909. readonly canPresent: boolean;
  61910. readonly hasExternalDisplay: boolean;
  61911. readonly hasOrientation: boolean;
  61912. readonly hasPosition: boolean;
  61913. readonly maxLayers: number;
  61914. }
  61915. interface VREyeParameters {
  61916. /** @deprecated */
  61917. readonly fieldOfView: VRFieldOfView;
  61918. readonly offset: Float32Array;
  61919. readonly renderHeight: number;
  61920. readonly renderWidth: number;
  61921. }
  61922. interface VRFieldOfView {
  61923. readonly downDegrees: number;
  61924. readonly leftDegrees: number;
  61925. readonly rightDegrees: number;
  61926. readonly upDegrees: number;
  61927. }
  61928. interface VRFrameData {
  61929. readonly leftProjectionMatrix: Float32Array;
  61930. readonly leftViewMatrix: Float32Array;
  61931. readonly pose: VRPose;
  61932. readonly rightProjectionMatrix: Float32Array;
  61933. readonly rightViewMatrix: Float32Array;
  61934. readonly timestamp: number;
  61935. }
  61936. interface VRPose {
  61937. readonly angularAcceleration: Float32Array | null;
  61938. readonly angularVelocity: Float32Array | null;
  61939. readonly linearAcceleration: Float32Array | null;
  61940. readonly linearVelocity: Float32Array | null;
  61941. readonly orientation: Float32Array | null;
  61942. readonly position: Float32Array | null;
  61943. readonly timestamp: number;
  61944. }
  61945. interface VRStageParameters {
  61946. sittingToStandingTransform?: Float32Array;
  61947. sizeX?: number;
  61948. sizeY?: number;
  61949. }
  61950. interface Navigator {
  61951. getVRDisplays(): Promise<VRDisplay[]>;
  61952. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  61953. }
  61954. interface Window {
  61955. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  61956. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  61957. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  61958. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61959. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  61960. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  61961. }
  61962. interface Gamepad {
  61963. readonly displayId: number;
  61964. }
  61965. type XRSessionMode =
  61966. | "inline"
  61967. | "immersive-vr"
  61968. | "immersive-ar";
  61969. type XRReferenceSpaceType =
  61970. | "viewer"
  61971. | "local"
  61972. | "local-floor"
  61973. | "bounded-floor"
  61974. | "unbounded";
  61975. type XREnvironmentBlendMode =
  61976. | "opaque"
  61977. | "additive"
  61978. | "alpha-blend";
  61979. type XRVisibilityState =
  61980. | "visible"
  61981. | "visible-blurred"
  61982. | "hidden";
  61983. type XRHandedness =
  61984. | "none"
  61985. | "left"
  61986. | "right";
  61987. type XRTargetRayMode =
  61988. | "gaze"
  61989. | "tracked-pointer"
  61990. | "screen";
  61991. type XREye =
  61992. | "none"
  61993. | "left"
  61994. | "right";
  61995. interface XRSpace extends EventTarget {
  61996. }
  61997. interface XRRenderState {
  61998. depthNear?: number;
  61999. depthFar?: number;
  62000. inlineVerticalFieldOfView?: number;
  62001. baseLayer?: XRWebGLLayer;
  62002. }
  62003. interface XRInputSource {
  62004. handedness: XRHandedness;
  62005. targetRayMode: XRTargetRayMode;
  62006. targetRaySpace: XRSpace;
  62007. gripSpace: XRSpace | undefined;
  62008. gamepad: Gamepad | undefined;
  62009. profiles: Array<string>;
  62010. }
  62011. interface XRSession {
  62012. addEventListener: Function;
  62013. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62014. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62015. requestAnimationFrame: Function;
  62016. end(): Promise<void>;
  62017. renderState: XRRenderState;
  62018. inputSources: Array<XRInputSource>;
  62019. }
  62020. interface XRReferenceSpace extends XRSpace {
  62021. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62022. onreset: any;
  62023. }
  62024. interface XRFrame {
  62025. session: XRSession;
  62026. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62027. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62028. }
  62029. interface XRViewerPose extends XRPose {
  62030. views: Array<XRView>;
  62031. }
  62032. interface XRPose {
  62033. transform: XRRigidTransform;
  62034. emulatedPosition: boolean;
  62035. }
  62036. declare var XRWebGLLayer: {
  62037. prototype: XRWebGLLayer;
  62038. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62039. };
  62040. interface XRWebGLLayer {
  62041. framebuffer: WebGLFramebuffer;
  62042. framebufferWidth: number;
  62043. framebufferHeight: number;
  62044. getViewport: Function;
  62045. }
  62046. interface XRRigidTransform {
  62047. position: DOMPointReadOnly;
  62048. orientation: DOMPointReadOnly;
  62049. matrix: Float32Array;
  62050. inverse: XRRigidTransform;
  62051. }
  62052. interface XRView {
  62053. eye: XREye;
  62054. projectionMatrix: Float32Array;
  62055. transform: XRRigidTransform;
  62056. }
  62057. interface XRInputSourceChangeEvent {
  62058. session: XRSession;
  62059. removed: Array<XRInputSource>;
  62060. added: Array<XRInputSource>;
  62061. }
  62062. declare module BABYLON.GUI {
  62063. /**
  62064. * Class used to specific a value and its associated unit
  62065. */
  62066. export class ValueAndUnit {
  62067. /** defines the unit to store */
  62068. unit: number;
  62069. /** defines a boolean indicating if the value can be negative */
  62070. negativeValueAllowed: boolean;
  62071. private _value;
  62072. private _originalUnit;
  62073. /**
  62074. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62075. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62076. */
  62077. ignoreAdaptiveScaling: boolean;
  62078. /**
  62079. * Creates a new ValueAndUnit
  62080. * @param value defines the value to store
  62081. * @param unit defines the unit to store
  62082. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62083. */
  62084. constructor(value: number,
  62085. /** defines the unit to store */
  62086. unit?: number,
  62087. /** defines a boolean indicating if the value can be negative */
  62088. negativeValueAllowed?: boolean);
  62089. /** Gets a boolean indicating if the value is a percentage */
  62090. readonly isPercentage: boolean;
  62091. /** Gets a boolean indicating if the value is store as pixel */
  62092. readonly isPixel: boolean;
  62093. /** Gets direct internal value */
  62094. readonly internalValue: number;
  62095. /**
  62096. * Gets value as pixel
  62097. * @param host defines the root host
  62098. * @param refValue defines the reference value for percentages
  62099. * @returns the value as pixel
  62100. */
  62101. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62102. /**
  62103. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62104. * @param value defines the value to store
  62105. * @param unit defines the unit to store
  62106. * @returns the current ValueAndUnit
  62107. */
  62108. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62109. /**
  62110. * Gets the value accordingly to its unit
  62111. * @param host defines the root host
  62112. * @returns the value
  62113. */
  62114. getValue(host: AdvancedDynamicTexture): number;
  62115. /**
  62116. * Gets a string representation of the value
  62117. * @param host defines the root host
  62118. * @param decimals defines an optional number of decimals to display
  62119. * @returns a string
  62120. */
  62121. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62122. /**
  62123. * Store a value parsed from a string
  62124. * @param source defines the source string
  62125. * @returns true if the value was successfully parsed
  62126. */
  62127. fromString(source: string | number): boolean;
  62128. private static _Regex;
  62129. private static _UNITMODE_PERCENTAGE;
  62130. private static _UNITMODE_PIXEL;
  62131. /** UNITMODE_PERCENTAGE */
  62132. static readonly UNITMODE_PERCENTAGE: number;
  62133. /** UNITMODE_PIXEL */
  62134. static readonly UNITMODE_PIXEL: number;
  62135. }
  62136. }
  62137. declare module BABYLON.GUI {
  62138. /**
  62139. * Define a style used by control to automatically setup properties based on a template.
  62140. * Only support font related properties so far
  62141. */
  62142. export class Style implements BABYLON.IDisposable {
  62143. private _fontFamily;
  62144. private _fontStyle;
  62145. private _fontWeight;
  62146. /** @hidden */
  62147. _host: AdvancedDynamicTexture;
  62148. /** @hidden */
  62149. _fontSize: ValueAndUnit;
  62150. /**
  62151. * BABYLON.Observable raised when the style values are changed
  62152. */
  62153. onChangedObservable: BABYLON.Observable<Style>;
  62154. /**
  62155. * Creates a new style object
  62156. * @param host defines the AdvancedDynamicTexture which hosts this style
  62157. */
  62158. constructor(host: AdvancedDynamicTexture);
  62159. /**
  62160. * Gets or sets the font size
  62161. */
  62162. fontSize: string | number;
  62163. /**
  62164. * Gets or sets the font family
  62165. */
  62166. fontFamily: string;
  62167. /**
  62168. * Gets or sets the font style
  62169. */
  62170. fontStyle: string;
  62171. /** Gets or sets font weight */
  62172. fontWeight: string;
  62173. /** Dispose all associated resources */
  62174. dispose(): void;
  62175. }
  62176. }
  62177. declare module BABYLON.GUI {
  62178. /**
  62179. * Class used to transport BABYLON.Vector2 information for pointer events
  62180. */
  62181. export class Vector2WithInfo extends BABYLON.Vector2 {
  62182. /** defines the current mouse button index */
  62183. buttonIndex: number;
  62184. /**
  62185. * Creates a new Vector2WithInfo
  62186. * @param source defines the vector2 data to transport
  62187. * @param buttonIndex defines the current mouse button index
  62188. */
  62189. constructor(source: BABYLON.Vector2,
  62190. /** defines the current mouse button index */
  62191. buttonIndex?: number);
  62192. }
  62193. /** Class used to provide 2D matrix features */
  62194. export class Matrix2D {
  62195. /** Gets the internal array of 6 floats used to store matrix data */
  62196. m: Float32Array;
  62197. /**
  62198. * Creates a new matrix
  62199. * @param m00 defines value for (0, 0)
  62200. * @param m01 defines value for (0, 1)
  62201. * @param m10 defines value for (1, 0)
  62202. * @param m11 defines value for (1, 1)
  62203. * @param m20 defines value for (2, 0)
  62204. * @param m21 defines value for (2, 1)
  62205. */
  62206. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62207. /**
  62208. * Fills the matrix from direct values
  62209. * @param m00 defines value for (0, 0)
  62210. * @param m01 defines value for (0, 1)
  62211. * @param m10 defines value for (1, 0)
  62212. * @param m11 defines value for (1, 1)
  62213. * @param m20 defines value for (2, 0)
  62214. * @param m21 defines value for (2, 1)
  62215. * @returns the current modified matrix
  62216. */
  62217. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62218. /**
  62219. * Gets matrix determinant
  62220. * @returns the determinant
  62221. */
  62222. determinant(): number;
  62223. /**
  62224. * Inverses the matrix and stores it in a target matrix
  62225. * @param result defines the target matrix
  62226. * @returns the current matrix
  62227. */
  62228. invertToRef(result: Matrix2D): Matrix2D;
  62229. /**
  62230. * Multiplies the current matrix with another one
  62231. * @param other defines the second operand
  62232. * @param result defines the target matrix
  62233. * @returns the current matrix
  62234. */
  62235. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62236. /**
  62237. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62238. * @param x defines the x coordinate to transform
  62239. * @param y defines the x coordinate to transform
  62240. * @param result defines the target vector2
  62241. * @returns the current matrix
  62242. */
  62243. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62244. /**
  62245. * Creates an identity matrix
  62246. * @returns a new matrix
  62247. */
  62248. static Identity(): Matrix2D;
  62249. /**
  62250. * Creates a translation matrix and stores it in a target matrix
  62251. * @param x defines the x coordinate of the translation
  62252. * @param y defines the y coordinate of the translation
  62253. * @param result defines the target matrix
  62254. */
  62255. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62256. /**
  62257. * Creates a scaling matrix and stores it in a target matrix
  62258. * @param x defines the x coordinate of the scaling
  62259. * @param y defines the y coordinate of the scaling
  62260. * @param result defines the target matrix
  62261. */
  62262. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  62263. /**
  62264. * Creates a rotation matrix and stores it in a target matrix
  62265. * @param angle defines the rotation angle
  62266. * @param result defines the target matrix
  62267. */
  62268. static RotationToRef(angle: number, result: Matrix2D): void;
  62269. private static _TempPreTranslationMatrix;
  62270. private static _TempPostTranslationMatrix;
  62271. private static _TempRotationMatrix;
  62272. private static _TempScalingMatrix;
  62273. private static _TempCompose0;
  62274. private static _TempCompose1;
  62275. private static _TempCompose2;
  62276. /**
  62277. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  62278. * @param tx defines the x coordinate of the translation
  62279. * @param ty defines the y coordinate of the translation
  62280. * @param angle defines the rotation angle
  62281. * @param scaleX defines the x coordinate of the scaling
  62282. * @param scaleY defines the y coordinate of the scaling
  62283. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  62284. * @param result defines the target matrix
  62285. */
  62286. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  62287. }
  62288. }
  62289. declare module BABYLON.GUI {
  62290. /**
  62291. * Class used to store 2D control sizes
  62292. */
  62293. export class Measure {
  62294. /** defines left coordinate */
  62295. left: number;
  62296. /** defines top coordinate */
  62297. top: number;
  62298. /** defines width dimension */
  62299. width: number;
  62300. /** defines height dimension */
  62301. height: number;
  62302. /**
  62303. * Creates a new measure
  62304. * @param left defines left coordinate
  62305. * @param top defines top coordinate
  62306. * @param width defines width dimension
  62307. * @param height defines height dimension
  62308. */
  62309. constructor(
  62310. /** defines left coordinate */
  62311. left: number,
  62312. /** defines top coordinate */
  62313. top: number,
  62314. /** defines width dimension */
  62315. width: number,
  62316. /** defines height dimension */
  62317. height: number);
  62318. /**
  62319. * Copy from another measure
  62320. * @param other defines the other measure to copy from
  62321. */
  62322. copyFrom(other: Measure): void;
  62323. /**
  62324. * Copy from a group of 4 floats
  62325. * @param left defines left coordinate
  62326. * @param top defines top coordinate
  62327. * @param width defines width dimension
  62328. * @param height defines height dimension
  62329. */
  62330. copyFromFloats(left: number, top: number, width: number, height: number): void;
  62331. /**
  62332. * Computes the axis aligned bounding box measure for two given measures
  62333. * @param a Input measure
  62334. * @param b Input measure
  62335. * @param result the resulting bounding measure
  62336. */
  62337. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  62338. /**
  62339. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  62340. * @param transform the matrix to transform the measure before computing the AABB
  62341. * @param result the resulting AABB
  62342. */
  62343. transformToRef(transform: Matrix2D, result: Measure): void;
  62344. /**
  62345. * Check equality between this measure and another one
  62346. * @param other defines the other measures
  62347. * @returns true if both measures are equals
  62348. */
  62349. isEqualsTo(other: Measure): boolean;
  62350. /**
  62351. * Creates an empty measure
  62352. * @returns a new measure
  62353. */
  62354. static Empty(): Measure;
  62355. }
  62356. }
  62357. declare module BABYLON.GUI {
  62358. /**
  62359. * Interface used to define a control that can receive focus
  62360. */
  62361. export interface IFocusableControl {
  62362. /**
  62363. * Function called when the control receives the focus
  62364. */
  62365. onFocus(): void;
  62366. /**
  62367. * Function called when the control loses the focus
  62368. */
  62369. onBlur(): void;
  62370. /**
  62371. * Function called to let the control handle keyboard events
  62372. * @param evt defines the current keyboard event
  62373. */
  62374. processKeyboard(evt: KeyboardEvent): void;
  62375. /**
  62376. * Function called to get the list of controls that should not steal the focus from this control
  62377. * @returns an array of controls
  62378. */
  62379. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62380. }
  62381. /**
  62382. * Class used to create texture to support 2D GUI elements
  62383. * @see http://doc.babylonjs.com/how_to/gui
  62384. */
  62385. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  62386. private _isDirty;
  62387. private _renderObserver;
  62388. private _resizeObserver;
  62389. private _preKeyboardObserver;
  62390. private _pointerMoveObserver;
  62391. private _pointerObserver;
  62392. private _canvasPointerOutObserver;
  62393. private _background;
  62394. /** @hidden */
  62395. _rootContainer: Container;
  62396. /** @hidden */
  62397. _lastPickedControl: Control;
  62398. /** @hidden */
  62399. _lastControlOver: {
  62400. [pointerId: number]: Control;
  62401. };
  62402. /** @hidden */
  62403. _lastControlDown: {
  62404. [pointerId: number]: Control;
  62405. };
  62406. /** @hidden */
  62407. _capturingControl: {
  62408. [pointerId: number]: Control;
  62409. };
  62410. /** @hidden */
  62411. _shouldBlockPointer: boolean;
  62412. /** @hidden */
  62413. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  62414. /** @hidden */
  62415. _linkedControls: Control[];
  62416. private _isFullscreen;
  62417. private _fullscreenViewport;
  62418. private _idealWidth;
  62419. private _idealHeight;
  62420. private _useSmallestIdeal;
  62421. private _renderAtIdealSize;
  62422. private _focusedControl;
  62423. private _blockNextFocusCheck;
  62424. private _renderScale;
  62425. private _rootCanvas;
  62426. private _cursorChanged;
  62427. /**
  62428. * Define type to string to ensure compatibility across browsers
  62429. * Safari doesn't support DataTransfer constructor
  62430. */
  62431. private _clipboardData;
  62432. /**
  62433. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  62434. */
  62435. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  62436. /**
  62437. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  62438. */
  62439. onControlPickedObservable: BABYLON.Observable<Control>;
  62440. /**
  62441. * BABYLON.Observable event triggered before layout is evaluated
  62442. */
  62443. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62444. /**
  62445. * BABYLON.Observable event triggered after the layout was evaluated
  62446. */
  62447. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62448. /**
  62449. * BABYLON.Observable event triggered before the texture is rendered
  62450. */
  62451. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62452. /**
  62453. * BABYLON.Observable event triggered after the texture was rendered
  62454. */
  62455. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  62456. /**
  62457. * Gets or sets a boolean defining if alpha is stored as premultiplied
  62458. */
  62459. premulAlpha: boolean;
  62460. /**
  62461. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  62462. * Useful when you want more antialiasing
  62463. */
  62464. renderScale: number;
  62465. /** Gets or sets the background color */
  62466. background: string;
  62467. /**
  62468. * Gets or sets the ideal width used to design controls.
  62469. * The GUI will then rescale everything accordingly
  62470. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62471. */
  62472. idealWidth: number;
  62473. /**
  62474. * Gets or sets the ideal height used to design controls.
  62475. * The GUI will then rescale everything accordingly
  62476. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62477. */
  62478. idealHeight: number;
  62479. /**
  62480. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  62481. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62482. */
  62483. useSmallestIdeal: boolean;
  62484. /**
  62485. * Gets or sets a boolean indicating if adaptive scaling must be used
  62486. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62487. */
  62488. renderAtIdealSize: boolean;
  62489. /**
  62490. * Gets the underlying layer used to render the texture when in fullscreen mode
  62491. */
  62492. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  62493. /**
  62494. * Gets the root container control
  62495. */
  62496. readonly rootContainer: Container;
  62497. /**
  62498. * Returns an array containing the root container.
  62499. * This is mostly used to let the Inspector introspects the ADT
  62500. * @returns an array containing the rootContainer
  62501. */
  62502. getChildren(): Array<Container>;
  62503. /**
  62504. * Will return all controls that are inside this texture
  62505. * @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
  62506. * @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
  62507. * @return all child controls
  62508. */
  62509. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  62510. /**
  62511. * Gets or sets the current focused control
  62512. */
  62513. focusedControl: BABYLON.Nullable<IFocusableControl>;
  62514. /**
  62515. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  62516. */
  62517. isForeground: boolean;
  62518. /**
  62519. * Gets or set information about clipboardData
  62520. */
  62521. clipboardData: string;
  62522. /**
  62523. * Creates a new AdvancedDynamicTexture
  62524. * @param name defines the name of the texture
  62525. * @param width defines the width of the texture
  62526. * @param height defines the height of the texture
  62527. * @param scene defines the hosting scene
  62528. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  62529. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  62530. */
  62531. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  62532. /**
  62533. * Get the current class name of the texture useful for serialization or dynamic coding.
  62534. * @returns "AdvancedDynamicTexture"
  62535. */
  62536. getClassName(): string;
  62537. /**
  62538. * Function used to execute a function on all controls
  62539. * @param func defines the function to execute
  62540. * @param container defines the container where controls belong. If null the root container will be used
  62541. */
  62542. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  62543. private _useInvalidateRectOptimization;
  62544. /**
  62545. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  62546. */
  62547. useInvalidateRectOptimization: boolean;
  62548. private _invalidatedRectangle;
  62549. /**
  62550. * Invalidates a rectangle area on the gui texture
  62551. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  62552. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  62553. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  62554. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  62555. */
  62556. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  62557. /**
  62558. * Marks the texture as dirty forcing a complete update
  62559. */
  62560. markAsDirty(): void;
  62561. /**
  62562. * Helper function used to create a new style
  62563. * @returns a new style
  62564. * @see http://doc.babylonjs.com/how_to/gui#styles
  62565. */
  62566. createStyle(): Style;
  62567. /**
  62568. * Adds a new control to the root container
  62569. * @param control defines the control to add
  62570. * @returns the current texture
  62571. */
  62572. addControl(control: Control): AdvancedDynamicTexture;
  62573. /**
  62574. * Removes a control from the root container
  62575. * @param control defines the control to remove
  62576. * @returns the current texture
  62577. */
  62578. removeControl(control: Control): AdvancedDynamicTexture;
  62579. /**
  62580. * Release all resources
  62581. */
  62582. dispose(): void;
  62583. private _onResize;
  62584. /** @hidden */
  62585. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  62586. /**
  62587. * Get screen coordinates for a vector3
  62588. * @param position defines the position to project
  62589. * @param worldMatrix defines the world matrix to use
  62590. * @returns the projected position
  62591. */
  62592. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  62593. private _checkUpdate;
  62594. private _clearMeasure;
  62595. private _render;
  62596. /** @hidden */
  62597. _changeCursor(cursor: string): void;
  62598. /** @hidden */
  62599. _registerLastControlDown(control: Control, pointerId: number): void;
  62600. private _doPicking;
  62601. /** @hidden */
  62602. _cleanControlAfterRemovalFromList(list: {
  62603. [pointerId: number]: Control;
  62604. }, control: Control): void;
  62605. /** @hidden */
  62606. _cleanControlAfterRemoval(control: Control): void;
  62607. /** Attach to all scene events required to support pointer events */
  62608. attach(): void;
  62609. /** @hidden */
  62610. private onClipboardCopy;
  62611. /** @hidden */
  62612. private onClipboardCut;
  62613. /** @hidden */
  62614. private onClipboardPaste;
  62615. /**
  62616. * Register the clipboard Events onto the canvas
  62617. */
  62618. registerClipboardEvents(): void;
  62619. /**
  62620. * Unregister the clipboard Events from the canvas
  62621. */
  62622. unRegisterClipboardEvents(): void;
  62623. /**
  62624. * Connect the texture to a hosting mesh to enable interactions
  62625. * @param mesh defines the mesh to attach to
  62626. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  62627. */
  62628. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  62629. /**
  62630. * Move the focus to a specific control
  62631. * @param control defines the control which will receive the focus
  62632. */
  62633. moveFocusToControl(control: IFocusableControl): void;
  62634. private _manageFocus;
  62635. private _attachToOnPointerOut;
  62636. /**
  62637. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  62638. * @param mesh defines the mesh which will receive the texture
  62639. * @param width defines the texture width (1024 by default)
  62640. * @param height defines the texture height (1024 by default)
  62641. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  62642. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  62643. * @returns a new AdvancedDynamicTexture
  62644. */
  62645. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  62646. /**
  62647. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  62648. * In this mode the texture will rely on a layer for its rendering.
  62649. * This allows it to be treated like any other layer.
  62650. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  62651. * LayerMask is set through advancedTexture.layer.layerMask
  62652. * @param name defines name for the texture
  62653. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  62654. * @param scene defines the hsoting scene
  62655. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  62656. * @returns a new AdvancedDynamicTexture
  62657. */
  62658. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  62659. }
  62660. }
  62661. declare module BABYLON.GUI {
  62662. /**
  62663. * Root class used for all 2D controls
  62664. * @see http://doc.babylonjs.com/how_to/gui#controls
  62665. */
  62666. export class Control {
  62667. /** defines the name of the control */
  62668. name?: string | undefined;
  62669. /**
  62670. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  62671. */
  62672. static AllowAlphaInheritance: boolean;
  62673. private _alpha;
  62674. private _alphaSet;
  62675. private _zIndex;
  62676. /** @hidden */
  62677. _host: AdvancedDynamicTexture;
  62678. /** Gets or sets the control parent */
  62679. parent: BABYLON.Nullable<Container>;
  62680. /** @hidden */
  62681. _currentMeasure: Measure;
  62682. private _fontFamily;
  62683. private _fontStyle;
  62684. private _fontWeight;
  62685. private _fontSize;
  62686. private _font;
  62687. /** @hidden */
  62688. _width: ValueAndUnit;
  62689. /** @hidden */
  62690. _height: ValueAndUnit;
  62691. /** @hidden */
  62692. protected _fontOffset: {
  62693. ascent: number;
  62694. height: number;
  62695. descent: number;
  62696. };
  62697. private _color;
  62698. private _style;
  62699. private _styleObserver;
  62700. /** @hidden */
  62701. protected _horizontalAlignment: number;
  62702. /** @hidden */
  62703. protected _verticalAlignment: number;
  62704. /** @hidden */
  62705. protected _isDirty: boolean;
  62706. /** @hidden */
  62707. protected _wasDirty: boolean;
  62708. /** @hidden */
  62709. _tempParentMeasure: Measure;
  62710. /** @hidden */
  62711. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  62712. /** @hidden */
  62713. protected _cachedParentMeasure: Measure;
  62714. private _paddingLeft;
  62715. private _paddingRight;
  62716. private _paddingTop;
  62717. private _paddingBottom;
  62718. /** @hidden */
  62719. _left: ValueAndUnit;
  62720. /** @hidden */
  62721. _top: ValueAndUnit;
  62722. private _scaleX;
  62723. private _scaleY;
  62724. private _rotation;
  62725. private _transformCenterX;
  62726. private _transformCenterY;
  62727. /** @hidden */
  62728. _transformMatrix: Matrix2D;
  62729. /** @hidden */
  62730. protected _invertTransformMatrix: Matrix2D;
  62731. /** @hidden */
  62732. protected _transformedPosition: BABYLON.Vector2;
  62733. private _isMatrixDirty;
  62734. private _cachedOffsetX;
  62735. private _cachedOffsetY;
  62736. private _isVisible;
  62737. private _isHighlighted;
  62738. /** @hidden */
  62739. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62740. private _fontSet;
  62741. private _dummyVector2;
  62742. private _downCount;
  62743. private _enterCount;
  62744. private _doNotRender;
  62745. private _downPointerIds;
  62746. protected _isEnabled: boolean;
  62747. protected _disabledColor: string;
  62748. /** @hidden */
  62749. protected _rebuildLayout: boolean;
  62750. /** @hidden */
  62751. _isClipped: boolean;
  62752. /** @hidden */
  62753. _tag: any;
  62754. /**
  62755. * 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
  62756. */
  62757. uniqueId: number;
  62758. /**
  62759. * Gets or sets an object used to store user defined information for the node
  62760. */
  62761. metadata: any;
  62762. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  62763. isHitTestVisible: boolean;
  62764. /** Gets or sets a boolean indicating if the control can block pointer events */
  62765. isPointerBlocker: boolean;
  62766. /** Gets or sets a boolean indicating if the control can be focusable */
  62767. isFocusInvisible: boolean;
  62768. /**
  62769. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  62770. * 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
  62771. */
  62772. clipChildren: boolean;
  62773. /**
  62774. * Gets or sets a boolean indicating that control content must be clipped
  62775. * 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
  62776. */
  62777. clipContent: boolean;
  62778. /**
  62779. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  62780. */
  62781. useBitmapCache: boolean;
  62782. private _cacheData;
  62783. private _shadowOffsetX;
  62784. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  62785. shadowOffsetX: number;
  62786. private _shadowOffsetY;
  62787. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  62788. shadowOffsetY: number;
  62789. private _shadowBlur;
  62790. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  62791. shadowBlur: number;
  62792. private _shadowColor;
  62793. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  62794. shadowColor: string;
  62795. /** Gets or sets the cursor to use when the control is hovered */
  62796. hoverCursor: string;
  62797. /** @hidden */
  62798. protected _linkOffsetX: ValueAndUnit;
  62799. /** @hidden */
  62800. protected _linkOffsetY: ValueAndUnit;
  62801. /** Gets the control type name */
  62802. readonly typeName: string;
  62803. /**
  62804. * Get the current class name of the control.
  62805. * @returns current class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * An event triggered when the pointer move over the control.
  62810. */
  62811. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  62812. /**
  62813. * An event triggered when the pointer move out of the control.
  62814. */
  62815. onPointerOutObservable: BABYLON.Observable<Control>;
  62816. /**
  62817. * An event triggered when the pointer taps the control
  62818. */
  62819. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  62820. /**
  62821. * An event triggered when pointer up
  62822. */
  62823. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  62824. /**
  62825. * An event triggered when a control is clicked on
  62826. */
  62827. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  62828. /**
  62829. * An event triggered when pointer enters the control
  62830. */
  62831. onPointerEnterObservable: BABYLON.Observable<Control>;
  62832. /**
  62833. * An event triggered when the control is marked as dirty
  62834. */
  62835. onDirtyObservable: BABYLON.Observable<Control>;
  62836. /**
  62837. * An event triggered before drawing the control
  62838. */
  62839. onBeforeDrawObservable: BABYLON.Observable<Control>;
  62840. /**
  62841. * An event triggered after the control was drawn
  62842. */
  62843. onAfterDrawObservable: BABYLON.Observable<Control>;
  62844. /**
  62845. * Get the hosting AdvancedDynamicTexture
  62846. */
  62847. readonly host: AdvancedDynamicTexture;
  62848. /** Gets or set information about font offsets (used to render and align text) */
  62849. fontOffset: {
  62850. ascent: number;
  62851. height: number;
  62852. descent: number;
  62853. };
  62854. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  62855. alpha: number;
  62856. /**
  62857. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  62858. */
  62859. isHighlighted: boolean;
  62860. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  62861. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62862. */
  62863. scaleX: number;
  62864. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  62865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62866. */
  62867. scaleY: number;
  62868. /** Gets or sets the rotation angle (0 by default)
  62869. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62870. */
  62871. rotation: number;
  62872. /** Gets or sets the transformation center on Y axis (0 by default)
  62873. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62874. */
  62875. transformCenterY: number;
  62876. /** Gets or sets the transformation center on X axis (0 by default)
  62877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  62878. */
  62879. transformCenterX: number;
  62880. /**
  62881. * Gets or sets the horizontal alignment
  62882. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62883. */
  62884. horizontalAlignment: number;
  62885. /**
  62886. * Gets or sets the vertical alignment
  62887. * @see http://doc.babylonjs.com/how_to/gui#alignments
  62888. */
  62889. verticalAlignment: number;
  62890. /**
  62891. * Gets or sets control width
  62892. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62893. */
  62894. width: string | number;
  62895. /**
  62896. * Gets or sets the control width in pixel
  62897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62898. */
  62899. widthInPixels: number;
  62900. /**
  62901. * Gets or sets control height
  62902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62903. */
  62904. height: string | number;
  62905. /**
  62906. * Gets or sets control height in pixel
  62907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62908. */
  62909. heightInPixels: number;
  62910. /** Gets or set font family */
  62911. fontFamily: string;
  62912. /** Gets or sets font style */
  62913. fontStyle: string;
  62914. /** Gets or sets font weight */
  62915. fontWeight: string;
  62916. /**
  62917. * Gets or sets style
  62918. * @see http://doc.babylonjs.com/how_to/gui#styles
  62919. */
  62920. style: BABYLON.Nullable<Style>;
  62921. /** @hidden */
  62922. readonly _isFontSizeInPercentage: boolean;
  62923. /** Gets or sets font size in pixels */
  62924. fontSizeInPixels: number;
  62925. /** Gets or sets font size */
  62926. fontSize: string | number;
  62927. /** Gets or sets foreground color */
  62928. color: string;
  62929. /** Gets or sets z index which is used to reorder controls on the z axis */
  62930. zIndex: number;
  62931. /** Gets or sets a boolean indicating if the control can be rendered */
  62932. notRenderable: boolean;
  62933. /** Gets or sets a boolean indicating if the control is visible */
  62934. isVisible: boolean;
  62935. /** Gets a boolean indicating that the control needs to update its rendering */
  62936. readonly isDirty: boolean;
  62937. /**
  62938. * Gets the current linked mesh (or null if none)
  62939. */
  62940. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62941. /**
  62942. * Gets or sets a value indicating the padding to use on the left of the control
  62943. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62944. */
  62945. paddingLeft: string | number;
  62946. /**
  62947. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  62948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62949. */
  62950. paddingLeftInPixels: number;
  62951. /**
  62952. * Gets or sets a value indicating the padding to use on the right of the control
  62953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62954. */
  62955. paddingRight: string | number;
  62956. /**
  62957. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  62958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62959. */
  62960. paddingRightInPixels: number;
  62961. /**
  62962. * Gets or sets a value indicating the padding to use on the top of the control
  62963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62964. */
  62965. paddingTop: string | number;
  62966. /**
  62967. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  62968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62969. */
  62970. paddingTopInPixels: number;
  62971. /**
  62972. * Gets or sets a value indicating the padding to use on the bottom of the control
  62973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62974. */
  62975. paddingBottom: string | number;
  62976. /**
  62977. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  62978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62979. */
  62980. paddingBottomInPixels: number;
  62981. /**
  62982. * Gets or sets a value indicating the left coordinate of the control
  62983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62984. */
  62985. left: string | number;
  62986. /**
  62987. * Gets or sets a value indicating the left coordinate in pixels of the control
  62988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62989. */
  62990. leftInPixels: number;
  62991. /**
  62992. * Gets or sets a value indicating the top coordinate of the control
  62993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62994. */
  62995. top: string | number;
  62996. /**
  62997. * Gets or sets a value indicating the top coordinate in pixels of the control
  62998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62999. */
  63000. topInPixels: number;
  63001. /**
  63002. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63003. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63004. */
  63005. linkOffsetX: string | number;
  63006. /**
  63007. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63008. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63009. */
  63010. linkOffsetXInPixels: number;
  63011. /**
  63012. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63013. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63014. */
  63015. linkOffsetY: string | number;
  63016. /**
  63017. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63018. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63019. */
  63020. linkOffsetYInPixels: number;
  63021. /** Gets the center coordinate on X axis */
  63022. readonly centerX: number;
  63023. /** Gets the center coordinate on Y axis */
  63024. readonly centerY: number;
  63025. /** Gets or sets if control is Enabled*/
  63026. isEnabled: boolean;
  63027. /** Gets or sets background color of control if it's disabled*/
  63028. disabledColor: string;
  63029. /**
  63030. * Creates a new control
  63031. * @param name defines the name of the control
  63032. */
  63033. constructor(
  63034. /** defines the name of the control */
  63035. name?: string | undefined);
  63036. /** @hidden */
  63037. protected _getTypeName(): string;
  63038. /**
  63039. * Gets the first ascendant in the hierarchy of the given type
  63040. * @param className defines the required type
  63041. * @returns the ascendant or null if not found
  63042. */
  63043. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63044. /** @hidden */
  63045. _resetFontCache(): void;
  63046. /**
  63047. * Determines if a container is an ascendant of the current control
  63048. * @param container defines the container to look for
  63049. * @returns true if the container is one of the ascendant of the control
  63050. */
  63051. isAscendant(container: Control): boolean;
  63052. /**
  63053. * Gets coordinates in local control space
  63054. * @param globalCoordinates defines the coordinates to transform
  63055. * @returns the new coordinates in local space
  63056. */
  63057. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63058. /**
  63059. * Gets coordinates in local control space
  63060. * @param globalCoordinates defines the coordinates to transform
  63061. * @param result defines the target vector2 where to store the result
  63062. * @returns the current control
  63063. */
  63064. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63065. /**
  63066. * Gets coordinates in parent local control space
  63067. * @param globalCoordinates defines the coordinates to transform
  63068. * @returns the new coordinates in parent local space
  63069. */
  63070. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63071. /**
  63072. * Move the current control to a vector3 position projected onto the screen.
  63073. * @param position defines the target position
  63074. * @param scene defines the hosting scene
  63075. */
  63076. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63077. /** @hidden */
  63078. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63079. /**
  63080. * Will return all controls that have this control as ascendant
  63081. * @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
  63082. * @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
  63083. * @return all child controls
  63084. */
  63085. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63086. /**
  63087. * Link current control with a target mesh
  63088. * @param mesh defines the mesh to link with
  63089. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63090. */
  63091. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63092. /** @hidden */
  63093. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63094. /** @hidden */
  63095. _offsetLeft(offset: number): void;
  63096. /** @hidden */
  63097. _offsetTop(offset: number): void;
  63098. /** @hidden */
  63099. _markMatrixAsDirty(): void;
  63100. /** @hidden */
  63101. _flagDescendantsAsMatrixDirty(): void;
  63102. /** @hidden */
  63103. _intersectsRect(rect: Measure): boolean;
  63104. /** @hidden */
  63105. protected invalidateRect(): void;
  63106. /** @hidden */
  63107. _markAsDirty(force?: boolean): void;
  63108. /** @hidden */
  63109. _markAllAsDirty(): void;
  63110. /** @hidden */
  63111. _link(host: AdvancedDynamicTexture): void;
  63112. /** @hidden */
  63113. protected _transform(context?: CanvasRenderingContext2D): void;
  63114. /** @hidden */
  63115. _renderHighlight(context: CanvasRenderingContext2D): void;
  63116. /** @hidden */
  63117. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63118. /** @hidden */
  63119. protected _applyStates(context: CanvasRenderingContext2D): void;
  63120. /** @hidden */
  63121. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63122. /** @hidden */
  63123. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63124. protected _evaluateClippingState(parentMeasure: Measure): void;
  63125. /** @hidden */
  63126. _measure(): void;
  63127. /** @hidden */
  63128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63129. /** @hidden */
  63130. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63131. /** @hidden */
  63132. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63133. /** @hidden */
  63134. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63135. private static _ClipMeasure;
  63136. private _tmpMeasureA;
  63137. private _clip;
  63138. /** @hidden */
  63139. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63140. /** @hidden */
  63141. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63142. /**
  63143. * Tests if a given coordinates belong to the current control
  63144. * @param x defines x coordinate to test
  63145. * @param y defines y coordinate to test
  63146. * @returns true if the coordinates are inside the control
  63147. */
  63148. contains(x: number, y: number): boolean;
  63149. /** @hidden */
  63150. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63151. /** @hidden */
  63152. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63153. /** @hidden */
  63154. _onPointerEnter(target: Control): boolean;
  63155. /** @hidden */
  63156. _onPointerOut(target: Control, force?: boolean): void;
  63157. /** @hidden */
  63158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63159. /** @hidden */
  63160. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63161. /** @hidden */
  63162. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63163. /** @hidden */
  63164. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63165. private _prepareFont;
  63166. /** Releases associated resources */
  63167. dispose(): void;
  63168. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63169. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63170. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63171. private static _VERTICAL_ALIGNMENT_TOP;
  63172. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63173. private static _VERTICAL_ALIGNMENT_CENTER;
  63174. /** HORIZONTAL_ALIGNMENT_LEFT */
  63175. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63176. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63177. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63178. /** HORIZONTAL_ALIGNMENT_CENTER */
  63179. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63180. /** VERTICAL_ALIGNMENT_TOP */
  63181. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63182. /** VERTICAL_ALIGNMENT_BOTTOM */
  63183. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63184. /** VERTICAL_ALIGNMENT_CENTER */
  63185. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63186. private static _FontHeightSizes;
  63187. /** @hidden */
  63188. static _GetFontOffset(font: string): {
  63189. ascent: number;
  63190. height: number;
  63191. descent: number;
  63192. };
  63193. /**
  63194. * Creates a stack panel that can be used to render headers
  63195. * @param control defines the control to associate with the header
  63196. * @param text defines the text of the header
  63197. * @param size defines the size of the header
  63198. * @param options defines options used to configure the header
  63199. * @returns a new StackPanel
  63200. * @ignore
  63201. * @hidden
  63202. */
  63203. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63204. isHorizontal: boolean;
  63205. controlFirst: boolean;
  63206. }) => any;
  63207. /** @hidden */
  63208. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63209. }
  63210. }
  63211. declare module BABYLON.GUI {
  63212. /**
  63213. * Root class for 2D containers
  63214. * @see http://doc.babylonjs.com/how_to/gui#containers
  63215. */
  63216. export class Container extends Control {
  63217. name?: string | undefined;
  63218. /** @hidden */
  63219. protected _children: Control[];
  63220. /** @hidden */
  63221. protected _measureForChildren: Measure;
  63222. /** @hidden */
  63223. protected _background: string;
  63224. /** @hidden */
  63225. protected _adaptWidthToChildren: boolean;
  63226. /** @hidden */
  63227. protected _adaptHeightToChildren: boolean;
  63228. /**
  63229. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63230. */
  63231. logLayoutCycleErrors: boolean;
  63232. /**
  63233. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63234. */
  63235. maxLayoutCycle: number;
  63236. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63237. adaptHeightToChildren: boolean;
  63238. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63239. adaptWidthToChildren: boolean;
  63240. /** Gets or sets background color */
  63241. background: string;
  63242. /** Gets the list of children */
  63243. readonly children: Control[];
  63244. /**
  63245. * Creates a new Container
  63246. * @param name defines the name of the container
  63247. */
  63248. constructor(name?: string | undefined);
  63249. protected _getTypeName(): string;
  63250. _flagDescendantsAsMatrixDirty(): void;
  63251. /**
  63252. * Gets a child using its name
  63253. * @param name defines the child name to look for
  63254. * @returns the child control if found
  63255. */
  63256. getChildByName(name: string): BABYLON.Nullable<Control>;
  63257. /**
  63258. * Gets a child using its type and its name
  63259. * @param name defines the child name to look for
  63260. * @param type defines the child type to look for
  63261. * @returns the child control if found
  63262. */
  63263. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  63264. /**
  63265. * Search for a specific control in children
  63266. * @param control defines the control to look for
  63267. * @returns true if the control is in child list
  63268. */
  63269. containsControl(control: Control): boolean;
  63270. /**
  63271. * Adds a new control to the current container
  63272. * @param control defines the control to add
  63273. * @returns the current container
  63274. */
  63275. addControl(control: BABYLON.Nullable<Control>): Container;
  63276. /**
  63277. * Removes all controls from the current container
  63278. * @returns the current container
  63279. */
  63280. clearControls(): Container;
  63281. /**
  63282. * Removes a control from the current container
  63283. * @param control defines the control to remove
  63284. * @returns the current container
  63285. */
  63286. removeControl(control: Control): Container;
  63287. /** @hidden */
  63288. _reOrderControl(control: Control): void;
  63289. /** @hidden */
  63290. _offsetLeft(offset: number): void;
  63291. /** @hidden */
  63292. _offsetTop(offset: number): void;
  63293. /** @hidden */
  63294. _markAllAsDirty(): void;
  63295. /** @hidden */
  63296. protected _localDraw(context: CanvasRenderingContext2D): void;
  63297. /** @hidden */
  63298. _link(host: AdvancedDynamicTexture): void;
  63299. /** @hidden */
  63300. protected _beforeLayout(): void;
  63301. /** @hidden */
  63302. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63303. /** @hidden */
  63304. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63305. protected _postMeasure(): void;
  63306. /** @hidden */
  63307. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  63308. /** @hidden */
  63309. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63310. /** @hidden */
  63311. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63312. /** @hidden */
  63313. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63314. /** Releases associated resources */
  63315. dispose(): void;
  63316. }
  63317. }
  63318. declare module BABYLON.GUI {
  63319. /** Class used to create rectangle container */
  63320. export class Rectangle extends Container {
  63321. name?: string | undefined;
  63322. private _thickness;
  63323. private _cornerRadius;
  63324. /** Gets or sets border thickness */
  63325. thickness: number;
  63326. /** Gets or sets the corner radius angle */
  63327. cornerRadius: number;
  63328. /**
  63329. * Creates a new Rectangle
  63330. * @param name defines the control name
  63331. */
  63332. constructor(name?: string | undefined);
  63333. protected _getTypeName(): string;
  63334. protected _localDraw(context: CanvasRenderingContext2D): void;
  63335. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63336. private _drawRoundedRect;
  63337. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63338. }
  63339. }
  63340. declare module BABYLON.GUI {
  63341. /**
  63342. * Enum that determines the text-wrapping mode to use.
  63343. */
  63344. export enum TextWrapping {
  63345. /**
  63346. * Clip the text when it's larger than Control.width; this is the default mode.
  63347. */
  63348. Clip = 0,
  63349. /**
  63350. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  63351. */
  63352. WordWrap = 1,
  63353. /**
  63354. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  63355. */
  63356. Ellipsis = 2
  63357. }
  63358. /**
  63359. * Class used to create text block control
  63360. */
  63361. export class TextBlock extends Control {
  63362. /**
  63363. * Defines the name of the control
  63364. */
  63365. name?: string | undefined;
  63366. private _text;
  63367. private _textWrapping;
  63368. private _textHorizontalAlignment;
  63369. private _textVerticalAlignment;
  63370. private _lines;
  63371. private _resizeToFit;
  63372. private _lineSpacing;
  63373. private _outlineWidth;
  63374. private _outlineColor;
  63375. /**
  63376. * An event triggered after the text is changed
  63377. */
  63378. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  63379. /**
  63380. * An event triggered after the text was broken up into lines
  63381. */
  63382. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  63383. /**
  63384. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  63385. */
  63386. readonly lines: any[];
  63387. /**
  63388. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63389. */
  63390. /**
  63391. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  63392. */
  63393. resizeToFit: boolean;
  63394. /**
  63395. * Gets or sets a boolean indicating if text must be wrapped
  63396. */
  63397. /**
  63398. * Gets or sets a boolean indicating if text must be wrapped
  63399. */
  63400. textWrapping: TextWrapping | boolean;
  63401. /**
  63402. * Gets or sets text to display
  63403. */
  63404. /**
  63405. * Gets or sets text to display
  63406. */
  63407. text: string;
  63408. /**
  63409. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63410. */
  63411. /**
  63412. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  63413. */
  63414. textHorizontalAlignment: number;
  63415. /**
  63416. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63417. */
  63418. /**
  63419. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  63420. */
  63421. textVerticalAlignment: number;
  63422. /**
  63423. * Gets or sets line spacing value
  63424. */
  63425. /**
  63426. * Gets or sets line spacing value
  63427. */
  63428. lineSpacing: string | number;
  63429. /**
  63430. * Gets or sets outlineWidth of the text to display
  63431. */
  63432. /**
  63433. * Gets or sets outlineWidth of the text to display
  63434. */
  63435. outlineWidth: number;
  63436. /**
  63437. * Gets or sets outlineColor of the text to display
  63438. */
  63439. /**
  63440. * Gets or sets outlineColor of the text to display
  63441. */
  63442. outlineColor: string;
  63443. /**
  63444. * Creates a new TextBlock object
  63445. * @param name defines the name of the control
  63446. * @param text defines the text to display (emptry string by default)
  63447. */
  63448. constructor(
  63449. /**
  63450. * Defines the name of the control
  63451. */
  63452. name?: string | undefined, text?: string);
  63453. protected _getTypeName(): string;
  63454. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63455. private _drawText;
  63456. /** @hidden */
  63457. _draw(context: CanvasRenderingContext2D): void;
  63458. protected _applyStates(context: CanvasRenderingContext2D): void;
  63459. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  63460. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  63461. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  63462. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  63463. protected _renderLines(context: CanvasRenderingContext2D): void;
  63464. /**
  63465. * Given a width constraint applied on the text block, find the expected height
  63466. * @returns expected height
  63467. */
  63468. computeExpectedHeight(): number;
  63469. dispose(): void;
  63470. }
  63471. }
  63472. declare module BABYLON.GUI {
  63473. /**
  63474. * Class used to create 2D images
  63475. */
  63476. export class Image extends Control {
  63477. name?: string | undefined;
  63478. private static _WorkingCanvas;
  63479. private _domImage;
  63480. private _imageWidth;
  63481. private _imageHeight;
  63482. private _loaded;
  63483. private _stretch;
  63484. private _source;
  63485. private _autoScale;
  63486. private _sourceLeft;
  63487. private _sourceTop;
  63488. private _sourceWidth;
  63489. private _sourceHeight;
  63490. private _cellWidth;
  63491. private _cellHeight;
  63492. private _cellId;
  63493. private _populateNinePatchSlicesFromImage;
  63494. private _sliceLeft;
  63495. private _sliceRight;
  63496. private _sliceTop;
  63497. private _sliceBottom;
  63498. private _detectPointerOnOpaqueOnly;
  63499. /**
  63500. * BABYLON.Observable notified when the content is loaded
  63501. */
  63502. onImageLoadedObservable: BABYLON.Observable<Image>;
  63503. /**
  63504. * Gets a boolean indicating that the content is loaded
  63505. */
  63506. readonly isLoaded: boolean;
  63507. /**
  63508. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  63509. */
  63510. populateNinePatchSlicesFromImage: boolean;
  63511. /**
  63512. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  63513. * Beware using this as this will comsume more memory as the image has to be stored twice
  63514. */
  63515. detectPointerOnOpaqueOnly: boolean;
  63516. /**
  63517. * Gets or sets the left value for slicing (9-patch)
  63518. */
  63519. sliceLeft: number;
  63520. /**
  63521. * Gets or sets the right value for slicing (9-patch)
  63522. */
  63523. sliceRight: number;
  63524. /**
  63525. * Gets or sets the top value for slicing (9-patch)
  63526. */
  63527. sliceTop: number;
  63528. /**
  63529. * Gets or sets the bottom value for slicing (9-patch)
  63530. */
  63531. sliceBottom: number;
  63532. /**
  63533. * Gets or sets the left coordinate in the source image
  63534. */
  63535. sourceLeft: number;
  63536. /**
  63537. * Gets or sets the top coordinate in the source image
  63538. */
  63539. sourceTop: number;
  63540. /**
  63541. * Gets or sets the width to capture in the source image
  63542. */
  63543. sourceWidth: number;
  63544. /**
  63545. * Gets or sets the height to capture in the source image
  63546. */
  63547. sourceHeight: number;
  63548. /**
  63549. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  63550. * @see http://doc.babylonjs.com/how_to/gui#image
  63551. */
  63552. autoScale: boolean;
  63553. /** Gets or sets the streching mode used by the image */
  63554. stretch: number;
  63555. /**
  63556. * Gets or sets the internal DOM image used to render the control
  63557. */
  63558. domImage: HTMLImageElement;
  63559. private _onImageLoaded;
  63560. private _extractNinePatchSliceDataFromImage;
  63561. /**
  63562. * Gets or sets image source url
  63563. */
  63564. source: BABYLON.Nullable<string>;
  63565. /**
  63566. * Gets or sets the cell width to use when animation sheet is enabled
  63567. * @see http://doc.babylonjs.com/how_to/gui#image
  63568. */
  63569. cellWidth: number;
  63570. /**
  63571. * Gets or sets the cell height to use when animation sheet is enabled
  63572. * @see http://doc.babylonjs.com/how_to/gui#image
  63573. */
  63574. cellHeight: number;
  63575. /**
  63576. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  63577. * @see http://doc.babylonjs.com/how_to/gui#image
  63578. */
  63579. cellId: number;
  63580. /**
  63581. * Creates a new Image
  63582. * @param name defines the control name
  63583. * @param url defines the image url
  63584. */
  63585. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  63586. /**
  63587. * Tests if a given coordinates belong to the current control
  63588. * @param x defines x coordinate to test
  63589. * @param y defines y coordinate to test
  63590. * @returns true if the coordinates are inside the control
  63591. */
  63592. contains(x: number, y: number): boolean;
  63593. protected _getTypeName(): string;
  63594. /** Force the control to synchronize with its content */
  63595. synchronizeSizeWithContent(): void;
  63596. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63597. private _prepareWorkingCanvasForOpaqueDetection;
  63598. private _drawImage;
  63599. _draw(context: CanvasRenderingContext2D): void;
  63600. private _renderCornerPatch;
  63601. private _renderNinePatch;
  63602. dispose(): void;
  63603. /** STRETCH_NONE */
  63604. static readonly STRETCH_NONE: number;
  63605. /** STRETCH_FILL */
  63606. static readonly STRETCH_FILL: number;
  63607. /** STRETCH_UNIFORM */
  63608. static readonly STRETCH_UNIFORM: number;
  63609. /** STRETCH_EXTEND */
  63610. static readonly STRETCH_EXTEND: number;
  63611. /** NINE_PATCH */
  63612. static readonly STRETCH_NINE_PATCH: number;
  63613. }
  63614. }
  63615. declare module BABYLON.GUI {
  63616. /**
  63617. * Class used to create 2D buttons
  63618. */
  63619. export class Button extends Rectangle {
  63620. name?: string | undefined;
  63621. /**
  63622. * Function called to generate a pointer enter animation
  63623. */
  63624. pointerEnterAnimation: () => void;
  63625. /**
  63626. * Function called to generate a pointer out animation
  63627. */
  63628. pointerOutAnimation: () => void;
  63629. /**
  63630. * Function called to generate a pointer down animation
  63631. */
  63632. pointerDownAnimation: () => void;
  63633. /**
  63634. * Function called to generate a pointer up animation
  63635. */
  63636. pointerUpAnimation: () => void;
  63637. /**
  63638. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  63639. */
  63640. delegatePickingToChildren: boolean;
  63641. private _image;
  63642. /**
  63643. * Returns the image part of the button (if any)
  63644. */
  63645. readonly image: BABYLON.Nullable<Image>;
  63646. private _textBlock;
  63647. /**
  63648. * Returns the image part of the button (if any)
  63649. */
  63650. readonly textBlock: BABYLON.Nullable<TextBlock>;
  63651. /**
  63652. * Creates a new Button
  63653. * @param name defines the name of the button
  63654. */
  63655. constructor(name?: string | undefined);
  63656. protected _getTypeName(): string;
  63657. /** @hidden */
  63658. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63659. /** @hidden */
  63660. _onPointerEnter(target: Control): boolean;
  63661. /** @hidden */
  63662. _onPointerOut(target: Control, force?: boolean): void;
  63663. /** @hidden */
  63664. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63665. /** @hidden */
  63666. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63667. /**
  63668. * Creates a new button made with an image and a text
  63669. * @param name defines the name of the button
  63670. * @param text defines the text of the button
  63671. * @param imageUrl defines the url of the image
  63672. * @returns a new Button
  63673. */
  63674. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  63675. /**
  63676. * Creates a new button made with an image
  63677. * @param name defines the name of the button
  63678. * @param imageUrl defines the url of the image
  63679. * @returns a new Button
  63680. */
  63681. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  63682. /**
  63683. * Creates a new button made with a text
  63684. * @param name defines the name of the button
  63685. * @param text defines the text of the button
  63686. * @returns a new Button
  63687. */
  63688. static CreateSimpleButton(name: string, text: string): Button;
  63689. /**
  63690. * Creates a new button made with an image and a centered text
  63691. * @param name defines the name of the button
  63692. * @param text defines the text of the button
  63693. * @param imageUrl defines the url of the image
  63694. * @returns a new Button
  63695. */
  63696. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  63697. }
  63698. }
  63699. declare module BABYLON.GUI {
  63700. /**
  63701. * Class used to create a 2D stack panel container
  63702. */
  63703. export class StackPanel extends Container {
  63704. name?: string | undefined;
  63705. private _isVertical;
  63706. private _manualWidth;
  63707. private _manualHeight;
  63708. private _doNotTrackManualChanges;
  63709. /**
  63710. * Gets or sets a boolean indicating that layou warnings should be ignored
  63711. */
  63712. ignoreLayoutWarnings: boolean;
  63713. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  63714. isVertical: boolean;
  63715. /**
  63716. * Gets or sets panel width.
  63717. * This value should not be set when in horizontal mode as it will be computed automatically
  63718. */
  63719. width: string | number;
  63720. /**
  63721. * Gets or sets panel height.
  63722. * This value should not be set when in vertical mode as it will be computed automatically
  63723. */
  63724. height: string | number;
  63725. /**
  63726. * Creates a new StackPanel
  63727. * @param name defines control name
  63728. */
  63729. constructor(name?: string | undefined);
  63730. protected _getTypeName(): string;
  63731. /** @hidden */
  63732. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63733. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63734. protected _postMeasure(): void;
  63735. }
  63736. }
  63737. declare module BABYLON.GUI {
  63738. /**
  63739. * Class used to represent a 2D checkbox
  63740. */
  63741. export class Checkbox extends Control {
  63742. name?: string | undefined;
  63743. private _isChecked;
  63744. private _background;
  63745. private _checkSizeRatio;
  63746. private _thickness;
  63747. /** Gets or sets border thickness */
  63748. thickness: number;
  63749. /**
  63750. * BABYLON.Observable raised when isChecked property changes
  63751. */
  63752. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63753. /** Gets or sets a value indicating the ratio between overall size and check size */
  63754. checkSizeRatio: number;
  63755. /** Gets or sets background color */
  63756. background: string;
  63757. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63758. isChecked: boolean;
  63759. /**
  63760. * Creates a new CheckBox
  63761. * @param name defines the control name
  63762. */
  63763. constructor(name?: string | undefined);
  63764. protected _getTypeName(): string;
  63765. /** @hidden */
  63766. _draw(context: CanvasRenderingContext2D): void;
  63767. /** @hidden */
  63768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63769. /**
  63770. * Utility function to easily create a checkbox with a header
  63771. * @param title defines the label to use for the header
  63772. * @param onValueChanged defines the callback to call when value changes
  63773. * @returns a StackPanel containing the checkbox and a textBlock
  63774. */
  63775. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  63776. }
  63777. }
  63778. declare module BABYLON.GUI {
  63779. /**
  63780. * Class used to store key control properties
  63781. */
  63782. export class KeyPropertySet {
  63783. /** Width */
  63784. width?: string;
  63785. /** Height */
  63786. height?: string;
  63787. /** Left padding */
  63788. paddingLeft?: string;
  63789. /** Right padding */
  63790. paddingRight?: string;
  63791. /** Top padding */
  63792. paddingTop?: string;
  63793. /** Bottom padding */
  63794. paddingBottom?: string;
  63795. /** Foreground color */
  63796. color?: string;
  63797. /** Background color */
  63798. background?: string;
  63799. }
  63800. /**
  63801. * Class used to create virtual keyboard
  63802. */
  63803. export class VirtualKeyboard extends StackPanel {
  63804. /** BABYLON.Observable raised when a key is pressed */
  63805. onKeyPressObservable: BABYLON.Observable<string>;
  63806. /** Gets or sets default key button width */
  63807. defaultButtonWidth: string;
  63808. /** Gets or sets default key button height */
  63809. defaultButtonHeight: string;
  63810. /** Gets or sets default key button left padding */
  63811. defaultButtonPaddingLeft: string;
  63812. /** Gets or sets default key button right padding */
  63813. defaultButtonPaddingRight: string;
  63814. /** Gets or sets default key button top padding */
  63815. defaultButtonPaddingTop: string;
  63816. /** Gets or sets default key button bottom padding */
  63817. defaultButtonPaddingBottom: string;
  63818. /** Gets or sets default key button foreground color */
  63819. defaultButtonColor: string;
  63820. /** Gets or sets default key button background color */
  63821. defaultButtonBackground: string;
  63822. /** Gets or sets shift button foreground color */
  63823. shiftButtonColor: string;
  63824. /** Gets or sets shift button thickness*/
  63825. selectedShiftThickness: number;
  63826. /** Gets shift key state */
  63827. shiftState: number;
  63828. protected _getTypeName(): string;
  63829. private _createKey;
  63830. /**
  63831. * Adds a new row of keys
  63832. * @param keys defines the list of keys to add
  63833. * @param propertySets defines the associated property sets
  63834. */
  63835. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  63836. /**
  63837. * Set the shift key to a specific state
  63838. * @param shiftState defines the new shift state
  63839. */
  63840. applyShiftState(shiftState: number): void;
  63841. private _currentlyConnectedInputText;
  63842. private _connectedInputTexts;
  63843. private _onKeyPressObserver;
  63844. /** Gets the input text control currently attached to the keyboard */
  63845. readonly connectedInputText: BABYLON.Nullable<InputText>;
  63846. /**
  63847. * Connects the keyboard with an input text control
  63848. *
  63849. * @param input defines the target control
  63850. */
  63851. connect(input: InputText): void;
  63852. /**
  63853. * Disconnects the keyboard from connected InputText controls
  63854. *
  63855. * @param input optionally defines a target control, otherwise all are disconnected
  63856. */
  63857. disconnect(input?: InputText): void;
  63858. private _removeConnectedInputObservables;
  63859. /**
  63860. * Release all resources
  63861. */
  63862. dispose(): void;
  63863. /**
  63864. * Creates a new keyboard using a default layout
  63865. *
  63866. * @param name defines control name
  63867. * @returns a new VirtualKeyboard
  63868. */
  63869. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  63870. }
  63871. }
  63872. declare module BABYLON.GUI {
  63873. /**
  63874. * Class used to create input text control
  63875. */
  63876. export class InputText extends Control implements IFocusableControl {
  63877. name?: string | undefined;
  63878. private _text;
  63879. private _placeholderText;
  63880. private _background;
  63881. private _focusedBackground;
  63882. private _focusedColor;
  63883. private _placeholderColor;
  63884. private _thickness;
  63885. private _margin;
  63886. private _autoStretchWidth;
  63887. private _maxWidth;
  63888. private _isFocused;
  63889. private _blinkTimeout;
  63890. private _blinkIsEven;
  63891. private _cursorOffset;
  63892. private _scrollLeft;
  63893. private _textWidth;
  63894. private _clickedCoordinate;
  63895. private _deadKey;
  63896. private _addKey;
  63897. private _currentKey;
  63898. private _isTextHighlightOn;
  63899. private _textHighlightColor;
  63900. private _highligherOpacity;
  63901. private _highlightedText;
  63902. private _startHighlightIndex;
  63903. private _endHighlightIndex;
  63904. private _cursorIndex;
  63905. private _onFocusSelectAll;
  63906. private _isPointerDown;
  63907. private _onClipboardObserver;
  63908. private _onPointerDblTapObserver;
  63909. /** @hidden */
  63910. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  63911. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  63912. promptMessage: string;
  63913. /** Force disable prompt on mobile device */
  63914. disableMobilePrompt: boolean;
  63915. /** BABYLON.Observable raised when the text changes */
  63916. onTextChangedObservable: BABYLON.Observable<InputText>;
  63917. /** BABYLON.Observable raised just before an entered character is to be added */
  63918. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  63919. /** BABYLON.Observable raised when the control gets the focus */
  63920. onFocusObservable: BABYLON.Observable<InputText>;
  63921. /** BABYLON.Observable raised when the control loses the focus */
  63922. onBlurObservable: BABYLON.Observable<InputText>;
  63923. /**Observable raised when the text is highlighted */
  63924. onTextHighlightObservable: BABYLON.Observable<InputText>;
  63925. /**Observable raised when copy event is triggered */
  63926. onTextCopyObservable: BABYLON.Observable<InputText>;
  63927. /** BABYLON.Observable raised when cut event is triggered */
  63928. onTextCutObservable: BABYLON.Observable<InputText>;
  63929. /** BABYLON.Observable raised when paste event is triggered */
  63930. onTextPasteObservable: BABYLON.Observable<InputText>;
  63931. /** BABYLON.Observable raised when a key event was processed */
  63932. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  63933. /** Gets or sets the maximum width allowed by the control */
  63934. maxWidth: string | number;
  63935. /** Gets the maximum width allowed by the control in pixels */
  63936. readonly maxWidthInPixels: number;
  63937. /** Gets or sets the text highlighter transparency; default: 0.4 */
  63938. highligherOpacity: number;
  63939. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  63940. onFocusSelectAll: boolean;
  63941. /** Gets or sets the text hightlight color */
  63942. textHighlightColor: string;
  63943. /** Gets or sets control margin */
  63944. margin: string;
  63945. /** Gets control margin in pixels */
  63946. readonly marginInPixels: number;
  63947. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  63948. autoStretchWidth: boolean;
  63949. /** Gets or sets border thickness */
  63950. thickness: number;
  63951. /** Gets or sets the background color when focused */
  63952. focusedBackground: string;
  63953. /** Gets or sets the background color when focused */
  63954. focusedColor: string;
  63955. /** Gets or sets the background color */
  63956. background: string;
  63957. /** Gets or sets the placeholder color */
  63958. placeholderColor: string;
  63959. /** Gets or sets the text displayed when the control is empty */
  63960. placeholderText: string;
  63961. /** Gets or sets the dead key flag */
  63962. deadKey: boolean;
  63963. /** Gets or sets the highlight text */
  63964. highlightedText: string;
  63965. /** Gets or sets if the current key should be added */
  63966. addKey: boolean;
  63967. /** Gets or sets the value of the current key being entered */
  63968. currentKey: string;
  63969. /** Gets or sets the text displayed in the control */
  63970. text: string;
  63971. /** Gets or sets control width */
  63972. width: string | number;
  63973. /**
  63974. * Creates a new InputText
  63975. * @param name defines the control name
  63976. * @param text defines the text of the control
  63977. */
  63978. constructor(name?: string | undefined, text?: string);
  63979. /** @hidden */
  63980. onBlur(): void;
  63981. /** @hidden */
  63982. onFocus(): void;
  63983. protected _getTypeName(): string;
  63984. /**
  63985. * Function called to get the list of controls that should not steal the focus from this control
  63986. * @returns an array of controls
  63987. */
  63988. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63989. /** @hidden */
  63990. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  63991. /** @hidden */
  63992. private _updateValueFromCursorIndex;
  63993. /** @hidden */
  63994. private _processDblClick;
  63995. /** @hidden */
  63996. private _selectAllText;
  63997. /**
  63998. * Handles the keyboard event
  63999. * @param evt Defines the KeyboardEvent
  64000. */
  64001. processKeyboard(evt: KeyboardEvent): void;
  64002. /** @hidden */
  64003. private _onCopyText;
  64004. /** @hidden */
  64005. private _onCutText;
  64006. /** @hidden */
  64007. private _onPasteText;
  64008. _draw(context: CanvasRenderingContext2D): void;
  64009. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64010. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64011. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64012. protected _beforeRenderText(text: string): string;
  64013. dispose(): void;
  64014. }
  64015. }
  64016. declare module BABYLON.GUI {
  64017. /**
  64018. * Class used to create a 2D grid container
  64019. */
  64020. export class Grid extends Container {
  64021. name?: string | undefined;
  64022. private _rowDefinitions;
  64023. private _columnDefinitions;
  64024. private _cells;
  64025. private _childControls;
  64026. /**
  64027. * Gets the number of columns
  64028. */
  64029. readonly columnCount: number;
  64030. /**
  64031. * Gets the number of rows
  64032. */
  64033. readonly rowCount: number;
  64034. /** Gets the list of children */
  64035. readonly children: Control[];
  64036. /** Gets the list of cells (e.g. the containers) */
  64037. readonly cells: {
  64038. [key: string]: Container;
  64039. };
  64040. /**
  64041. * Gets the definition of a specific row
  64042. * @param index defines the index of the row
  64043. * @returns the row definition
  64044. */
  64045. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64046. /**
  64047. * Gets the definition of a specific column
  64048. * @param index defines the index of the column
  64049. * @returns the column definition
  64050. */
  64051. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64052. /**
  64053. * Adds a new row to the grid
  64054. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64055. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64056. * @returns the current grid
  64057. */
  64058. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64059. /**
  64060. * Adds a new column to the grid
  64061. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64062. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64063. * @returns the current grid
  64064. */
  64065. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64066. /**
  64067. * Update a row definition
  64068. * @param index defines the index of the row to update
  64069. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64070. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64071. * @returns the current grid
  64072. */
  64073. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64074. /**
  64075. * Update a column definition
  64076. * @param index defines the index of the column to update
  64077. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64078. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64079. * @returns the current grid
  64080. */
  64081. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64082. /**
  64083. * Gets the list of children stored in a specific cell
  64084. * @param row defines the row to check
  64085. * @param column defines the column to check
  64086. * @returns the list of controls
  64087. */
  64088. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64089. /**
  64090. * Gets a string representing the child cell info (row x column)
  64091. * @param child defines the control to get info from
  64092. * @returns a string containing the child cell info (row x column)
  64093. */
  64094. getChildCellInfo(child: Control): string;
  64095. private _removeCell;
  64096. private _offsetCell;
  64097. /**
  64098. * Remove a column definition at specified index
  64099. * @param index defines the index of the column to remove
  64100. * @returns the current grid
  64101. */
  64102. removeColumnDefinition(index: number): Grid;
  64103. /**
  64104. * Remove a row definition at specified index
  64105. * @param index defines the index of the row to remove
  64106. * @returns the current grid
  64107. */
  64108. removeRowDefinition(index: number): Grid;
  64109. /**
  64110. * Adds a new control to the current grid
  64111. * @param control defines the control to add
  64112. * @param row defines the row where to add the control (0 by default)
  64113. * @param column defines the column where to add the control (0 by default)
  64114. * @returns the current grid
  64115. */
  64116. addControl(control: Control, row?: number, column?: number): Grid;
  64117. /**
  64118. * Removes a control from the current container
  64119. * @param control defines the control to remove
  64120. * @returns the current container
  64121. */
  64122. removeControl(control: Control): Container;
  64123. /**
  64124. * Creates a new Grid
  64125. * @param name defines control name
  64126. */
  64127. constructor(name?: string | undefined);
  64128. protected _getTypeName(): string;
  64129. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64130. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64131. _flagDescendantsAsMatrixDirty(): void;
  64132. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64133. /** Releases associated resources */
  64134. dispose(): void;
  64135. }
  64136. }
  64137. declare module BABYLON.GUI {
  64138. /** Class used to create color pickers */
  64139. export class ColorPicker extends Control {
  64140. name?: string | undefined;
  64141. private static _Epsilon;
  64142. private _colorWheelCanvas;
  64143. private _value;
  64144. private _tmpColor;
  64145. private _pointerStartedOnSquare;
  64146. private _pointerStartedOnWheel;
  64147. private _squareLeft;
  64148. private _squareTop;
  64149. private _squareSize;
  64150. private _h;
  64151. private _s;
  64152. private _v;
  64153. private _lastPointerDownID;
  64154. /**
  64155. * BABYLON.Observable raised when the value changes
  64156. */
  64157. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64158. /** Gets or sets the color of the color picker */
  64159. value: BABYLON.Color3;
  64160. /**
  64161. * Gets or sets control width
  64162. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64163. */
  64164. width: string | number;
  64165. /**
  64166. * Gets or sets control height
  64167. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64168. */
  64169. /** Gets or sets control height */
  64170. height: string | number;
  64171. /** Gets or sets control size */
  64172. size: string | number;
  64173. /**
  64174. * Creates a new ColorPicker
  64175. * @param name defines the control name
  64176. */
  64177. constructor(name?: string | undefined);
  64178. protected _getTypeName(): string;
  64179. /** @hidden */
  64180. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64181. private _updateSquareProps;
  64182. private _drawGradientSquare;
  64183. private _drawCircle;
  64184. private _createColorWheelCanvas;
  64185. /** @hidden */
  64186. _draw(context: CanvasRenderingContext2D): void;
  64187. private _pointerIsDown;
  64188. private _updateValueFromPointer;
  64189. private _isPointOnSquare;
  64190. private _isPointOnWheel;
  64191. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64192. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64193. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64194. /**
  64195. * This function expands the color picker by creating a color picker dialog with manual
  64196. * color value input and the ability to save colors into an array to be used later in
  64197. * subsequent launches of the dialogue.
  64198. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64199. * @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.
  64200. * @returns picked color as a hex string and the saved colors array as hex strings.
  64201. */
  64202. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64203. pickerWidth?: string;
  64204. pickerHeight?: string;
  64205. headerHeight?: string;
  64206. lastColor?: string;
  64207. swatchLimit?: number;
  64208. numSwatchesPerLine?: number;
  64209. savedColors?: Array<string>;
  64210. }): Promise<{
  64211. savedColors?: string[];
  64212. pickedColor: string;
  64213. }>;
  64214. }
  64215. }
  64216. declare module BABYLON.GUI {
  64217. /** Class used to create 2D ellipse containers */
  64218. export class Ellipse extends Container {
  64219. name?: string | undefined;
  64220. private _thickness;
  64221. /** Gets or sets border thickness */
  64222. thickness: number;
  64223. /**
  64224. * Creates a new Ellipse
  64225. * @param name defines the control name
  64226. */
  64227. constructor(name?: string | undefined);
  64228. protected _getTypeName(): string;
  64229. protected _localDraw(context: CanvasRenderingContext2D): void;
  64230. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64231. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64232. }
  64233. }
  64234. declare module BABYLON.GUI {
  64235. /**
  64236. * Class used to create a password control
  64237. */
  64238. export class InputPassword extends InputText {
  64239. protected _beforeRenderText(text: string): string;
  64240. }
  64241. }
  64242. declare module BABYLON.GUI {
  64243. /** Class used to render 2D lines */
  64244. export class Line extends Control {
  64245. name?: string | undefined;
  64246. private _lineWidth;
  64247. private _x1;
  64248. private _y1;
  64249. private _x2;
  64250. private _y2;
  64251. private _dash;
  64252. private _connectedControl;
  64253. private _connectedControlDirtyObserver;
  64254. /** Gets or sets the dash pattern */
  64255. dash: Array<number>;
  64256. /** Gets or sets the control connected with the line end */
  64257. connectedControl: Control;
  64258. /** Gets or sets start coordinates on X axis */
  64259. x1: string | number;
  64260. /** Gets or sets start coordinates on Y axis */
  64261. y1: string | number;
  64262. /** Gets or sets end coordinates on X axis */
  64263. x2: string | number;
  64264. /** Gets or sets end coordinates on Y axis */
  64265. y2: string | number;
  64266. /** Gets or sets line width */
  64267. lineWidth: number;
  64268. /** Gets or sets horizontal alignment */
  64269. horizontalAlignment: number;
  64270. /** Gets or sets vertical alignment */
  64271. verticalAlignment: number;
  64272. private readonly _effectiveX2;
  64273. private readonly _effectiveY2;
  64274. /**
  64275. * Creates a new Line
  64276. * @param name defines the control name
  64277. */
  64278. constructor(name?: string | undefined);
  64279. protected _getTypeName(): string;
  64280. _draw(context: CanvasRenderingContext2D): void;
  64281. _measure(): void;
  64282. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64283. /**
  64284. * Move one end of the line given 3D cartesian coordinates.
  64285. * @param position Targeted world position
  64286. * @param scene BABYLON.Scene
  64287. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64288. */
  64289. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  64290. /**
  64291. * Move one end of the line to a position in screen absolute space.
  64292. * @param projectedPosition Position in screen absolute space (X, Y)
  64293. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  64294. */
  64295. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  64296. }
  64297. }
  64298. declare module BABYLON.GUI {
  64299. /**
  64300. * Class used to store a point for a MultiLine object.
  64301. * The point can be pure 2D coordinates, a mesh or a control
  64302. */
  64303. export class MultiLinePoint {
  64304. private _multiLine;
  64305. private _x;
  64306. private _y;
  64307. private _control;
  64308. private _mesh;
  64309. private _controlObserver;
  64310. private _meshObserver;
  64311. /** @hidden */
  64312. _point: BABYLON.Vector2;
  64313. /**
  64314. * Creates a new MultiLinePoint
  64315. * @param multiLine defines the source MultiLine object
  64316. */
  64317. constructor(multiLine: MultiLine);
  64318. /** Gets or sets x coordinate */
  64319. x: string | number;
  64320. /** Gets or sets y coordinate */
  64321. y: string | number;
  64322. /** Gets or sets the control associated with this point */
  64323. control: BABYLON.Nullable<Control>;
  64324. /** Gets or sets the mesh associated with this point */
  64325. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64326. /** Resets links */
  64327. resetLinks(): void;
  64328. /**
  64329. * Gets a translation vector
  64330. * @returns the translation vector
  64331. */
  64332. translate(): BABYLON.Vector2;
  64333. private _translatePoint;
  64334. /** Release associated resources */
  64335. dispose(): void;
  64336. }
  64337. }
  64338. declare module BABYLON.GUI {
  64339. /**
  64340. * Class used to create multi line control
  64341. */
  64342. export class MultiLine extends Control {
  64343. name?: string | undefined;
  64344. private _lineWidth;
  64345. private _dash;
  64346. private _points;
  64347. private _minX;
  64348. private _minY;
  64349. private _maxX;
  64350. private _maxY;
  64351. /**
  64352. * Creates a new MultiLine
  64353. * @param name defines the control name
  64354. */
  64355. constructor(name?: string | undefined);
  64356. /** Gets or sets dash pattern */
  64357. dash: Array<number>;
  64358. /**
  64359. * Gets point stored at specified index
  64360. * @param index defines the index to look for
  64361. * @returns the requested point if found
  64362. */
  64363. getAt(index: number): MultiLinePoint;
  64364. /** Function called when a point is updated */
  64365. onPointUpdate: () => void;
  64366. /**
  64367. * Adds new points to the point collection
  64368. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  64369. * @returns the list of created MultiLinePoint
  64370. */
  64371. add(...items: (AbstractMesh | Control | {
  64372. x: string | number;
  64373. y: string | number;
  64374. })[]): MultiLinePoint[];
  64375. /**
  64376. * Adds a new point to the point collection
  64377. * @param item defines the item (mesh, control or 2d coordiantes) to add
  64378. * @returns the created MultiLinePoint
  64379. */
  64380. push(item?: (AbstractMesh | Control | {
  64381. x: string | number;
  64382. y: string | number;
  64383. })): MultiLinePoint;
  64384. /**
  64385. * Remove a specific value or point from the active point collection
  64386. * @param value defines the value or point to remove
  64387. */
  64388. remove(value: number | MultiLinePoint): void;
  64389. /**
  64390. * Resets this object to initial state (no point)
  64391. */
  64392. reset(): void;
  64393. /**
  64394. * Resets all links
  64395. */
  64396. resetLinks(): void;
  64397. /** Gets or sets line width */
  64398. lineWidth: number;
  64399. horizontalAlignment: number;
  64400. verticalAlignment: number;
  64401. protected _getTypeName(): string;
  64402. _draw(context: CanvasRenderingContext2D): void;
  64403. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64404. _measure(): void;
  64405. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64406. dispose(): void;
  64407. }
  64408. }
  64409. declare module BABYLON.GUI {
  64410. /**
  64411. * Class used to create radio button controls
  64412. */
  64413. export class RadioButton extends Control {
  64414. name?: string | undefined;
  64415. private _isChecked;
  64416. private _background;
  64417. private _checkSizeRatio;
  64418. private _thickness;
  64419. /** Gets or sets border thickness */
  64420. thickness: number;
  64421. /** Gets or sets group name */
  64422. group: string;
  64423. /** BABYLON.Observable raised when isChecked is changed */
  64424. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64425. /** Gets or sets a value indicating the ratio between overall size and check size */
  64426. checkSizeRatio: number;
  64427. /** Gets or sets background color */
  64428. background: string;
  64429. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64430. isChecked: boolean;
  64431. /**
  64432. * Creates a new RadioButton
  64433. * @param name defines the control name
  64434. */
  64435. constructor(name?: string | undefined);
  64436. protected _getTypeName(): string;
  64437. _draw(context: CanvasRenderingContext2D): void;
  64438. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64439. /**
  64440. * Utility function to easily create a radio button with a header
  64441. * @param title defines the label to use for the header
  64442. * @param group defines the group to use for the radio button
  64443. * @param isChecked defines the initial state of the radio button
  64444. * @param onValueChanged defines the callback to call when value changes
  64445. * @returns a StackPanel containing the radio button and a textBlock
  64446. */
  64447. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  64448. }
  64449. }
  64450. declare module BABYLON.GUI {
  64451. /**
  64452. * Class used to create slider controls
  64453. */
  64454. export class BaseSlider extends Control {
  64455. name?: string | undefined;
  64456. protected _thumbWidth: ValueAndUnit;
  64457. private _minimum;
  64458. private _maximum;
  64459. private _value;
  64460. private _isVertical;
  64461. protected _barOffset: ValueAndUnit;
  64462. private _isThumbClamped;
  64463. protected _displayThumb: boolean;
  64464. private _step;
  64465. private _lastPointerDownID;
  64466. protected _effectiveBarOffset: number;
  64467. protected _renderLeft: number;
  64468. protected _renderTop: number;
  64469. protected _renderWidth: number;
  64470. protected _renderHeight: number;
  64471. protected _backgroundBoxLength: number;
  64472. protected _backgroundBoxThickness: number;
  64473. protected _effectiveThumbThickness: number;
  64474. /** BABYLON.Observable raised when the sldier value changes */
  64475. onValueChangedObservable: BABYLON.Observable<number>;
  64476. /** Gets or sets a boolean indicating if the thumb must be rendered */
  64477. displayThumb: boolean;
  64478. /** Gets or sets a step to apply to values (0 by default) */
  64479. step: number;
  64480. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  64481. barOffset: string | number;
  64482. /** Gets main bar offset in pixels*/
  64483. readonly barOffsetInPixels: number;
  64484. /** Gets or sets thumb width */
  64485. thumbWidth: string | number;
  64486. /** Gets thumb width in pixels */
  64487. readonly thumbWidthInPixels: number;
  64488. /** Gets or sets minimum value */
  64489. minimum: number;
  64490. /** Gets or sets maximum value */
  64491. maximum: number;
  64492. /** Gets or sets current value */
  64493. value: number;
  64494. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  64495. isVertical: boolean;
  64496. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  64497. isThumbClamped: boolean;
  64498. /**
  64499. * Creates a new BaseSlider
  64500. * @param name defines the control name
  64501. */
  64502. constructor(name?: string | undefined);
  64503. protected _getTypeName(): string;
  64504. protected _getThumbPosition(): number;
  64505. protected _getThumbThickness(type: string): number;
  64506. protected _prepareRenderingData(type: string): void;
  64507. private _pointerIsDown;
  64508. /** @hidden */
  64509. protected _updateValueFromPointer(x: number, y: number): void;
  64510. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64511. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64512. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64513. }
  64514. }
  64515. declare module BABYLON.GUI {
  64516. /**
  64517. * Class used to create slider controls
  64518. */
  64519. export class Slider extends BaseSlider {
  64520. name?: string | undefined;
  64521. private _background;
  64522. private _borderColor;
  64523. private _isThumbCircle;
  64524. protected _displayValueBar: boolean;
  64525. /** Gets or sets a boolean indicating if the value bar must be rendered */
  64526. displayValueBar: boolean;
  64527. /** Gets or sets border color */
  64528. borderColor: string;
  64529. /** Gets or sets background color */
  64530. background: string;
  64531. /** Gets or sets a boolean indicating if the thumb should be round or square */
  64532. isThumbCircle: boolean;
  64533. /**
  64534. * Creates a new Slider
  64535. * @param name defines the control name
  64536. */
  64537. constructor(name?: string | undefined);
  64538. protected _getTypeName(): string;
  64539. _draw(context: CanvasRenderingContext2D): void;
  64540. }
  64541. }
  64542. declare module BABYLON.GUI {
  64543. /** Class used to create a RadioGroup
  64544. * which contains groups of radio buttons
  64545. */
  64546. export class SelectorGroup {
  64547. /** name of SelectorGroup */
  64548. name: string;
  64549. private _groupPanel;
  64550. private _selectors;
  64551. private _groupHeader;
  64552. /**
  64553. * Creates a new SelectorGroup
  64554. * @param name of group, used as a group heading
  64555. */
  64556. constructor(
  64557. /** name of SelectorGroup */
  64558. name: string);
  64559. /** Gets the groupPanel of the SelectorGroup */
  64560. readonly groupPanel: StackPanel;
  64561. /** Gets the selectors array */
  64562. readonly selectors: StackPanel[];
  64563. /** Gets and sets the group header */
  64564. header: string;
  64565. /** @hidden */
  64566. private _addGroupHeader;
  64567. /** @hidden*/
  64568. _getSelector(selectorNb: number): StackPanel | undefined;
  64569. /** Removes the selector at the given position
  64570. * @param selectorNb the position of the selector within the group
  64571. */
  64572. removeSelector(selectorNb: number): void;
  64573. }
  64574. /** Class used to create a CheckboxGroup
  64575. * which contains groups of checkbox buttons
  64576. */
  64577. export class CheckboxGroup extends SelectorGroup {
  64578. /** Adds a checkbox as a control
  64579. * @param text is the label for the selector
  64580. * @param func is the function called when the Selector is checked
  64581. * @param checked is true when Selector is checked
  64582. */
  64583. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  64584. /** @hidden */
  64585. _setSelectorLabel(selectorNb: number, label: string): void;
  64586. /** @hidden */
  64587. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64588. /** @hidden */
  64589. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64590. /** @hidden */
  64591. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64592. }
  64593. /** Class used to create a RadioGroup
  64594. * which contains groups of radio buttons
  64595. */
  64596. export class RadioGroup extends SelectorGroup {
  64597. private _selectNb;
  64598. /** Adds a radio button as a control
  64599. * @param label is the label for the selector
  64600. * @param func is the function called when the Selector is checked
  64601. * @param checked is true when Selector is checked
  64602. */
  64603. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  64604. /** @hidden */
  64605. _setSelectorLabel(selectorNb: number, label: string): void;
  64606. /** @hidden */
  64607. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64608. /** @hidden */
  64609. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64610. /** @hidden */
  64611. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64612. }
  64613. /** Class used to create a SliderGroup
  64614. * which contains groups of slider buttons
  64615. */
  64616. export class SliderGroup extends SelectorGroup {
  64617. /**
  64618. * Adds a slider to the SelectorGroup
  64619. * @param label is the label for the SliderBar
  64620. * @param func is the function called when the Slider moves
  64621. * @param unit is a string describing the units used, eg degrees or metres
  64622. * @param min is the minimum value for the Slider
  64623. * @param max is the maximum value for the Slider
  64624. * @param value is the start value for the Slider between min and max
  64625. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  64626. */
  64627. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  64628. /** @hidden */
  64629. _setSelectorLabel(selectorNb: number, label: string): void;
  64630. /** @hidden */
  64631. _setSelectorLabelColor(selectorNb: number, color: string): void;
  64632. /** @hidden */
  64633. _setSelectorButtonColor(selectorNb: number, color: string): void;
  64634. /** @hidden */
  64635. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  64636. }
  64637. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  64638. * @see http://doc.babylonjs.com/how_to/selector
  64639. */
  64640. export class SelectionPanel extends Rectangle {
  64641. /** name of SelectionPanel */
  64642. name: string;
  64643. /** an array of SelectionGroups */
  64644. groups: SelectorGroup[];
  64645. private _panel;
  64646. private _buttonColor;
  64647. private _buttonBackground;
  64648. private _headerColor;
  64649. private _barColor;
  64650. private _barHeight;
  64651. private _spacerHeight;
  64652. private _labelColor;
  64653. private _groups;
  64654. private _bars;
  64655. /**
  64656. * Creates a new SelectionPanel
  64657. * @param name of SelectionPanel
  64658. * @param groups is an array of SelectionGroups
  64659. */
  64660. constructor(
  64661. /** name of SelectionPanel */
  64662. name: string,
  64663. /** an array of SelectionGroups */
  64664. groups?: SelectorGroup[]);
  64665. protected _getTypeName(): string;
  64666. /** Gets or sets the headerColor */
  64667. headerColor: string;
  64668. private _setHeaderColor;
  64669. /** Gets or sets the button color */
  64670. buttonColor: string;
  64671. private _setbuttonColor;
  64672. /** Gets or sets the label color */
  64673. labelColor: string;
  64674. private _setLabelColor;
  64675. /** Gets or sets the button background */
  64676. buttonBackground: string;
  64677. private _setButtonBackground;
  64678. /** Gets or sets the color of separator bar */
  64679. barColor: string;
  64680. private _setBarColor;
  64681. /** Gets or sets the height of separator bar */
  64682. barHeight: string;
  64683. private _setBarHeight;
  64684. /** Gets or sets the height of spacers*/
  64685. spacerHeight: string;
  64686. private _setSpacerHeight;
  64687. /** Adds a bar between groups */
  64688. private _addSpacer;
  64689. /** Add a group to the selection panel
  64690. * @param group is the selector group to add
  64691. */
  64692. addGroup(group: SelectorGroup): void;
  64693. /** Remove the group from the given position
  64694. * @param groupNb is the position of the group in the list
  64695. */
  64696. removeGroup(groupNb: number): void;
  64697. /** Change a group header label
  64698. * @param label is the new group header label
  64699. * @param groupNb is the number of the group to relabel
  64700. * */
  64701. setHeaderName(label: string, groupNb: number): void;
  64702. /** Change selector label to the one given
  64703. * @param label is the new selector label
  64704. * @param groupNb is the number of the groupcontaining the selector
  64705. * @param selectorNb is the number of the selector within a group to relabel
  64706. * */
  64707. relabel(label: string, groupNb: number, selectorNb: number): void;
  64708. /** For a given group position remove the selector at the given position
  64709. * @param groupNb is the number of the group to remove the selector from
  64710. * @param selectorNb is the number of the selector within the group
  64711. */
  64712. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  64713. /** For a given group position of correct type add a checkbox button
  64714. * @param groupNb is the number of the group to remove the selector from
  64715. * @param label is the label for the selector
  64716. * @param func is the function called when the Selector is checked
  64717. * @param checked is true when Selector is checked
  64718. */
  64719. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64720. /** For a given group position of correct type add a radio button
  64721. * @param groupNb is the number of the group to remove the selector from
  64722. * @param label is the label for the selector
  64723. * @param func is the function called when the Selector is checked
  64724. * @param checked is true when Selector is checked
  64725. */
  64726. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  64727. /**
  64728. * For a given slider group add a slider
  64729. * @param groupNb is the number of the group to add the slider to
  64730. * @param label is the label for the Slider
  64731. * @param func is the function called when the Slider moves
  64732. * @param unit is a string describing the units used, eg degrees or metres
  64733. * @param min is the minimum value for the Slider
  64734. * @param max is the maximum value for the Slider
  64735. * @param value is the start value for the Slider between min and max
  64736. * @param onVal is the function used to format the value displayed, eg radians to degrees
  64737. */
  64738. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  64739. }
  64740. }
  64741. declare module BABYLON.GUI {
  64742. /**
  64743. * Class used to hold a the container for ScrollViewer
  64744. * @hidden
  64745. */
  64746. export class _ScrollViewerWindow extends Container {
  64747. parentClientWidth: number;
  64748. parentClientHeight: number;
  64749. /**
  64750. * Creates a new ScrollViewerWindow
  64751. * @param name of ScrollViewerWindow
  64752. */
  64753. constructor(name?: string);
  64754. protected _getTypeName(): string;
  64755. /** @hidden */
  64756. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64757. protected _postMeasure(): void;
  64758. }
  64759. }
  64760. declare module BABYLON.GUI {
  64761. /**
  64762. * Class used to create slider controls
  64763. */
  64764. export class ScrollBar extends BaseSlider {
  64765. name?: string | undefined;
  64766. private _background;
  64767. private _borderColor;
  64768. private _thumbMeasure;
  64769. /** Gets or sets border color */
  64770. borderColor: string;
  64771. /** Gets or sets background color */
  64772. background: string;
  64773. /**
  64774. * Creates a new Slider
  64775. * @param name defines the control name
  64776. */
  64777. constructor(name?: string | undefined);
  64778. protected _getTypeName(): string;
  64779. protected _getThumbThickness(): number;
  64780. _draw(context: CanvasRenderingContext2D): void;
  64781. private _first;
  64782. private _originX;
  64783. private _originY;
  64784. /** @hidden */
  64785. protected _updateValueFromPointer(x: number, y: number): void;
  64786. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64787. }
  64788. }
  64789. declare module BABYLON.GUI {
  64790. /**
  64791. * Class used to hold a viewer window and sliders in a grid
  64792. */
  64793. export class ScrollViewer extends Rectangle {
  64794. private _grid;
  64795. private _horizontalBarSpace;
  64796. private _verticalBarSpace;
  64797. private _dragSpace;
  64798. private _horizontalBar;
  64799. private _verticalBar;
  64800. private _barColor;
  64801. private _barBackground;
  64802. private _barSize;
  64803. private _endLeft;
  64804. private _endTop;
  64805. private _window;
  64806. private _pointerIsOver;
  64807. private _wheelPrecision;
  64808. private _onPointerObserver;
  64809. private _clientWidth;
  64810. private _clientHeight;
  64811. /**
  64812. * Gets the horizontal scrollbar
  64813. */
  64814. readonly horizontalBar: ScrollBar;
  64815. /**
  64816. * Gets the vertical scrollbar
  64817. */
  64818. readonly verticalBar: ScrollBar;
  64819. /**
  64820. * Adds a new control to the current container
  64821. * @param control defines the control to add
  64822. * @returns the current container
  64823. */
  64824. addControl(control: BABYLON.Nullable<Control>): Container;
  64825. /**
  64826. * Removes a control from the current container
  64827. * @param control defines the control to remove
  64828. * @returns the current container
  64829. */
  64830. removeControl(control: Control): Container;
  64831. /** Gets the list of children */
  64832. readonly children: Control[];
  64833. _flagDescendantsAsMatrixDirty(): void;
  64834. /**
  64835. * Creates a new ScrollViewer
  64836. * @param name of ScrollViewer
  64837. */
  64838. constructor(name?: string);
  64839. /** Reset the scroll viewer window to initial size */
  64840. resetWindow(): void;
  64841. protected _getTypeName(): string;
  64842. private _buildClientSizes;
  64843. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64844. protected _postMeasure(): void;
  64845. /**
  64846. * Gets or sets the mouse wheel precision
  64847. * from 0 to 1 with a default value of 0.05
  64848. * */
  64849. wheelPrecision: number;
  64850. /** Gets or sets the bar color */
  64851. barColor: string;
  64852. /** Gets or sets the size of the bar */
  64853. barSize: number;
  64854. /** Gets or sets the bar background */
  64855. barBackground: string;
  64856. /** @hidden */
  64857. private _updateScroller;
  64858. _link(host: AdvancedDynamicTexture): void;
  64859. /** @hidden */
  64860. private _attachWheel;
  64861. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64862. /** Releases associated resources */
  64863. dispose(): void;
  64864. }
  64865. }
  64866. declare module BABYLON.GUI {
  64867. /** Class used to render a grid */
  64868. export class DisplayGrid extends Control {
  64869. name?: string | undefined;
  64870. private _cellWidth;
  64871. private _cellHeight;
  64872. private _minorLineTickness;
  64873. private _minorLineColor;
  64874. private _majorLineTickness;
  64875. private _majorLineColor;
  64876. private _majorLineFrequency;
  64877. private _background;
  64878. private _displayMajorLines;
  64879. private _displayMinorLines;
  64880. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  64881. displayMinorLines: boolean;
  64882. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  64883. displayMajorLines: boolean;
  64884. /** Gets or sets background color (Black by default) */
  64885. background: string;
  64886. /** Gets or sets the width of each cell (20 by default) */
  64887. cellWidth: number;
  64888. /** Gets or sets the height of each cell (20 by default) */
  64889. cellHeight: number;
  64890. /** Gets or sets the tickness of minor lines (1 by default) */
  64891. minorLineTickness: number;
  64892. /** Gets or sets the color of minor lines (DarkGray by default) */
  64893. minorLineColor: string;
  64894. /** Gets or sets the tickness of major lines (2 by default) */
  64895. majorLineTickness: number;
  64896. /** Gets or sets the color of major lines (White by default) */
  64897. majorLineColor: string;
  64898. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  64899. majorLineFrequency: number;
  64900. /**
  64901. * Creates a new GridDisplayRectangle
  64902. * @param name defines the control name
  64903. */
  64904. constructor(name?: string | undefined);
  64905. _draw(context: CanvasRenderingContext2D): void;
  64906. protected _getTypeName(): string;
  64907. }
  64908. }
  64909. declare module BABYLON.GUI {
  64910. /**
  64911. * Class used to create slider controls based on images
  64912. */
  64913. export class ImageBasedSlider extends BaseSlider {
  64914. name?: string | undefined;
  64915. private _backgroundImage;
  64916. private _thumbImage;
  64917. private _valueBarImage;
  64918. private _tempMeasure;
  64919. displayThumb: boolean;
  64920. /**
  64921. * Gets or sets the image used to render the background
  64922. */
  64923. backgroundImage: Image;
  64924. /**
  64925. * Gets or sets the image used to render the value bar
  64926. */
  64927. valueBarImage: Image;
  64928. /**
  64929. * Gets or sets the image used to render the thumb
  64930. */
  64931. thumbImage: Image;
  64932. /**
  64933. * Creates a new ImageBasedSlider
  64934. * @param name defines the control name
  64935. */
  64936. constructor(name?: string | undefined);
  64937. protected _getTypeName(): string;
  64938. _draw(context: CanvasRenderingContext2D): void;
  64939. }
  64940. }
  64941. declare module BABYLON.GUI {
  64942. /**
  64943. * Forcing an export so that this code will execute
  64944. * @hidden
  64945. */
  64946. const name = "Statics";
  64947. }
  64948. declare module BABYLON.GUI {
  64949. /**
  64950. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  64951. */
  64952. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  64953. /**
  64954. * Define the instrumented AdvancedDynamicTexture.
  64955. */
  64956. texture: AdvancedDynamicTexture;
  64957. private _captureRenderTime;
  64958. private _renderTime;
  64959. private _captureLayoutTime;
  64960. private _layoutTime;
  64961. private _onBeginRenderObserver;
  64962. private _onEndRenderObserver;
  64963. private _onBeginLayoutObserver;
  64964. private _onEndLayoutObserver;
  64965. /**
  64966. * Gets the perf counter used to capture render time
  64967. */
  64968. readonly renderTimeCounter: BABYLON.PerfCounter;
  64969. /**
  64970. * Gets the perf counter used to capture layout time
  64971. */
  64972. readonly layoutTimeCounter: BABYLON.PerfCounter;
  64973. /**
  64974. * Enable or disable the render time capture
  64975. */
  64976. captureRenderTime: boolean;
  64977. /**
  64978. * Enable or disable the layout time capture
  64979. */
  64980. captureLayoutTime: boolean;
  64981. /**
  64982. * Instantiates a new advanced dynamic texture instrumentation.
  64983. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  64984. * @param texture Defines the AdvancedDynamicTexture to instrument
  64985. */
  64986. constructor(
  64987. /**
  64988. * Define the instrumented AdvancedDynamicTexture.
  64989. */
  64990. texture: AdvancedDynamicTexture);
  64991. /**
  64992. * Dispose and release associated resources.
  64993. */
  64994. dispose(): void;
  64995. }
  64996. }
  64997. declare module BABYLON.GUI {
  64998. /**
  64999. * Class used to create containers for controls
  65000. */
  65001. export class Container3D extends Control3D {
  65002. private _blockLayout;
  65003. /**
  65004. * Gets the list of child controls
  65005. */
  65006. protected _children: Control3D[];
  65007. /**
  65008. * Gets the list of child controls
  65009. */
  65010. readonly children: Array<Control3D>;
  65011. /**
  65012. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65013. * This is helpful to optimize layout operation when adding multiple children in a row
  65014. */
  65015. blockLayout: boolean;
  65016. /**
  65017. * Creates a new container
  65018. * @param name defines the container name
  65019. */
  65020. constructor(name?: string);
  65021. /**
  65022. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65023. * @returns the current container
  65024. */
  65025. updateLayout(): Container3D;
  65026. /**
  65027. * Gets a boolean indicating if the given control is in the children of this control
  65028. * @param control defines the control to check
  65029. * @returns true if the control is in the child list
  65030. */
  65031. containsControl(control: Control3D): boolean;
  65032. /**
  65033. * Adds a control to the children of this control
  65034. * @param control defines the control to add
  65035. * @returns the current container
  65036. */
  65037. addControl(control: Control3D): Container3D;
  65038. /**
  65039. * This function will be called everytime a new control is added
  65040. */
  65041. protected _arrangeChildren(): void;
  65042. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65043. /**
  65044. * Removes a control from the children of this control
  65045. * @param control defines the control to remove
  65046. * @returns the current container
  65047. */
  65048. removeControl(control: Control3D): Container3D;
  65049. protected _getTypeName(): string;
  65050. /**
  65051. * Releases all associated resources
  65052. */
  65053. dispose(): void;
  65054. /** Control rotation will remain unchanged */
  65055. static readonly UNSET_ORIENTATION: number;
  65056. /** Control will rotate to make it look at sphere central axis */
  65057. static readonly FACEORIGIN_ORIENTATION: number;
  65058. /** Control will rotate to make it look back at sphere central axis */
  65059. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65060. /** Control will rotate to look at z axis (0, 0, 1) */
  65061. static readonly FACEFORWARD_ORIENTATION: number;
  65062. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65063. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65064. }
  65065. }
  65066. declare module BABYLON.GUI {
  65067. /**
  65068. * Class used to manage 3D user interface
  65069. * @see http://doc.babylonjs.com/how_to/gui3d
  65070. */
  65071. export class GUI3DManager implements BABYLON.IDisposable {
  65072. private _scene;
  65073. private _sceneDisposeObserver;
  65074. private _utilityLayer;
  65075. private _rootContainer;
  65076. private _pointerObserver;
  65077. private _pointerOutObserver;
  65078. /** @hidden */
  65079. _lastPickedControl: Control3D;
  65080. /** @hidden */
  65081. _lastControlOver: {
  65082. [pointerId: number]: Control3D;
  65083. };
  65084. /** @hidden */
  65085. _lastControlDown: {
  65086. [pointerId: number]: Control3D;
  65087. };
  65088. /**
  65089. * BABYLON.Observable raised when the point picked by the pointer events changed
  65090. */
  65091. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65092. /** @hidden */
  65093. _sharedMaterials: {
  65094. [key: string]: BABYLON.Material;
  65095. };
  65096. /** Gets the hosting scene */
  65097. readonly scene: BABYLON.Scene;
  65098. /** Gets associated utility layer */
  65099. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65100. /**
  65101. * Creates a new GUI3DManager
  65102. * @param scene
  65103. */
  65104. constructor(scene?: BABYLON.Scene);
  65105. private _handlePointerOut;
  65106. private _doPicking;
  65107. /**
  65108. * Gets the root container
  65109. */
  65110. readonly rootContainer: Container3D;
  65111. /**
  65112. * Gets a boolean indicating if the given control is in the root child list
  65113. * @param control defines the control to check
  65114. * @returns true if the control is in the root child list
  65115. */
  65116. containsControl(control: Control3D): boolean;
  65117. /**
  65118. * Adds a control to the root child list
  65119. * @param control defines the control to add
  65120. * @returns the current manager
  65121. */
  65122. addControl(control: Control3D): GUI3DManager;
  65123. /**
  65124. * Removes a control from the root child list
  65125. * @param control defines the control to remove
  65126. * @returns the current container
  65127. */
  65128. removeControl(control: Control3D): GUI3DManager;
  65129. /**
  65130. * Releases all associated resources
  65131. */
  65132. dispose(): void;
  65133. }
  65134. }
  65135. declare module BABYLON.GUI {
  65136. /**
  65137. * Class used to transport BABYLON.Vector3 information for pointer events
  65138. */
  65139. export class Vector3WithInfo extends BABYLON.Vector3 {
  65140. /** defines the current mouse button index */
  65141. buttonIndex: number;
  65142. /**
  65143. * Creates a new Vector3WithInfo
  65144. * @param source defines the vector3 data to transport
  65145. * @param buttonIndex defines the current mouse button index
  65146. */
  65147. constructor(source: BABYLON.Vector3,
  65148. /** defines the current mouse button index */
  65149. buttonIndex?: number);
  65150. }
  65151. }
  65152. declare module BABYLON.GUI {
  65153. /**
  65154. * Class used as base class for controls
  65155. */
  65156. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65157. /** Defines the control name */
  65158. name?: string | undefined;
  65159. /** @hidden */
  65160. _host: GUI3DManager;
  65161. private _node;
  65162. private _downCount;
  65163. private _enterCount;
  65164. private _downPointerIds;
  65165. private _isVisible;
  65166. /** Gets or sets the control position in world space */
  65167. position: BABYLON.Vector3;
  65168. /** Gets or sets the control scaling in world space */
  65169. scaling: BABYLON.Vector3;
  65170. /** Callback used to start pointer enter animation */
  65171. pointerEnterAnimation: () => void;
  65172. /** Callback used to start pointer out animation */
  65173. pointerOutAnimation: () => void;
  65174. /** Callback used to start pointer down animation */
  65175. pointerDownAnimation: () => void;
  65176. /** Callback used to start pointer up animation */
  65177. pointerUpAnimation: () => void;
  65178. /**
  65179. * An event triggered when the pointer move over the control
  65180. */
  65181. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65182. /**
  65183. * An event triggered when the pointer move out of the control
  65184. */
  65185. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65186. /**
  65187. * An event triggered when the pointer taps the control
  65188. */
  65189. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65190. /**
  65191. * An event triggered when pointer is up
  65192. */
  65193. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65194. /**
  65195. * An event triggered when a control is clicked on (with a mouse)
  65196. */
  65197. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65198. /**
  65199. * An event triggered when pointer enters the control
  65200. */
  65201. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65202. /**
  65203. * Gets or sets the parent container
  65204. */
  65205. parent: BABYLON.Nullable<Container3D>;
  65206. private _behaviors;
  65207. /**
  65208. * Gets the list of attached behaviors
  65209. * @see http://doc.babylonjs.com/features/behaviour
  65210. */
  65211. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65212. /**
  65213. * Attach a behavior to the control
  65214. * @see http://doc.babylonjs.com/features/behaviour
  65215. * @param behavior defines the behavior to attach
  65216. * @returns the current control
  65217. */
  65218. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65219. /**
  65220. * Remove an attached behavior
  65221. * @see http://doc.babylonjs.com/features/behaviour
  65222. * @param behavior defines the behavior to attach
  65223. * @returns the current control
  65224. */
  65225. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65226. /**
  65227. * Gets an attached behavior by name
  65228. * @param name defines the name of the behavior to look for
  65229. * @see http://doc.babylonjs.com/features/behaviour
  65230. * @returns null if behavior was not found else the requested behavior
  65231. */
  65232. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65233. /** Gets or sets a boolean indicating if the control is visible */
  65234. isVisible: boolean;
  65235. /**
  65236. * Creates a new control
  65237. * @param name defines the control name
  65238. */
  65239. constructor(
  65240. /** Defines the control name */
  65241. name?: string | undefined);
  65242. /**
  65243. * Gets a string representing the class name
  65244. */
  65245. readonly typeName: string;
  65246. /**
  65247. * Get the current class name of the control.
  65248. * @returns current class name
  65249. */
  65250. getClassName(): string;
  65251. protected _getTypeName(): string;
  65252. /**
  65253. * Gets the transform node used by this control
  65254. */
  65255. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65256. /**
  65257. * Gets the mesh used to render this control
  65258. */
  65259. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65260. /**
  65261. * Link the control as child of the given node
  65262. * @param node defines the node to link to. Use null to unlink the control
  65263. * @returns the current control
  65264. */
  65265. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  65266. /** @hidden **/
  65267. _prepareNode(scene: BABYLON.Scene): void;
  65268. /**
  65269. * Node creation.
  65270. * Can be overriden by children
  65271. * @param scene defines the scene where the node must be attached
  65272. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  65273. */
  65274. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65275. /**
  65276. * Affect a material to the given mesh
  65277. * @param mesh defines the mesh which will represent the control
  65278. */
  65279. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65280. /** @hidden */
  65281. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  65282. /** @hidden */
  65283. _onPointerEnter(target: Control3D): boolean;
  65284. /** @hidden */
  65285. _onPointerOut(target: Control3D): void;
  65286. /** @hidden */
  65287. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65288. /** @hidden */
  65289. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65290. /** @hidden */
  65291. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65292. /** @hidden */
  65293. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  65294. /** @hidden */
  65295. _disposeNode(): void;
  65296. /**
  65297. * Releases all associated resources
  65298. */
  65299. dispose(): void;
  65300. }
  65301. }
  65302. declare module BABYLON.GUI {
  65303. /**
  65304. * Class used as a root to all buttons
  65305. */
  65306. export class AbstractButton3D extends Control3D {
  65307. /**
  65308. * Creates a new button
  65309. * @param name defines the control name
  65310. */
  65311. constructor(name?: string);
  65312. protected _getTypeName(): string;
  65313. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65314. }
  65315. }
  65316. declare module BABYLON.GUI {
  65317. /**
  65318. * Class used to create a button in 3D
  65319. */
  65320. export class Button3D extends AbstractButton3D {
  65321. /** @hidden */
  65322. protected _currentMaterial: BABYLON.Material;
  65323. private _facadeTexture;
  65324. private _content;
  65325. private _contentResolution;
  65326. private _contentScaleRatio;
  65327. /**
  65328. * Gets or sets the texture resolution used to render content (512 by default)
  65329. */
  65330. contentResolution: BABYLON.int;
  65331. /**
  65332. * Gets or sets the texture scale ratio used to render content (2 by default)
  65333. */
  65334. contentScaleRatio: number;
  65335. protected _disposeFacadeTexture(): void;
  65336. protected _resetContent(): void;
  65337. /**
  65338. * Creates a new button
  65339. * @param name defines the control name
  65340. */
  65341. constructor(name?: string);
  65342. /**
  65343. * Gets or sets the GUI 2D content used to display the button's facade
  65344. */
  65345. content: Control;
  65346. /**
  65347. * Apply the facade texture (created from the content property).
  65348. * This function can be overloaded by child classes
  65349. * @param facadeTexture defines the AdvancedDynamicTexture to use
  65350. */
  65351. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65352. protected _getTypeName(): string;
  65353. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65354. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65355. /**
  65356. * Releases all associated resources
  65357. */
  65358. dispose(): void;
  65359. }
  65360. }
  65361. declare module BABYLON.GUI {
  65362. /**
  65363. * Abstract class used to create a container panel deployed on the surface of a volume
  65364. */
  65365. export abstract class VolumeBasedPanel extends Container3D {
  65366. private _columns;
  65367. private _rows;
  65368. private _rowThenColum;
  65369. private _orientation;
  65370. protected _cellWidth: number;
  65371. protected _cellHeight: number;
  65372. /**
  65373. * Gets or sets the distance between elements
  65374. */
  65375. margin: number;
  65376. /**
  65377. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  65378. * | Value | Type | Description |
  65379. * | ----- | ----------------------------------- | ----------- |
  65380. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  65381. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  65382. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  65383. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  65384. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  65385. */
  65386. orientation: number;
  65387. /**
  65388. * Gets or sets the number of columns requested (10 by default).
  65389. * The panel will automatically compute the number of rows based on number of child controls.
  65390. */
  65391. columns: BABYLON.int;
  65392. /**
  65393. * Gets or sets a the number of rows requested.
  65394. * The panel will automatically compute the number of columns based on number of child controls.
  65395. */
  65396. rows: BABYLON.int;
  65397. /**
  65398. * Creates new VolumeBasedPanel
  65399. */
  65400. constructor();
  65401. protected _arrangeChildren(): void;
  65402. /** Child classes must implement this function to provide correct control positioning */
  65403. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65404. /** Child classes can implement this function to provide additional processing */
  65405. protected _finalProcessing(): void;
  65406. }
  65407. }
  65408. declare module BABYLON.GUI {
  65409. /**
  65410. * Class used to create a container panel deployed on the surface of a cylinder
  65411. */
  65412. export class CylinderPanel extends VolumeBasedPanel {
  65413. private _radius;
  65414. /**
  65415. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  65416. */
  65417. radius: BABYLON.float;
  65418. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65419. private _cylindricalMapping;
  65420. }
  65421. }
  65422. declare module BABYLON.GUI {
  65423. /** @hidden */
  65424. export var fluentVertexShader: {
  65425. name: string;
  65426. shader: string;
  65427. };
  65428. }
  65429. declare module BABYLON.GUI {
  65430. /** @hidden */
  65431. export var fluentPixelShader: {
  65432. name: string;
  65433. shader: string;
  65434. };
  65435. }
  65436. declare module BABYLON.GUI {
  65437. /** @hidden */
  65438. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  65439. INNERGLOW: boolean;
  65440. BORDER: boolean;
  65441. HOVERLIGHT: boolean;
  65442. TEXTURE: boolean;
  65443. constructor();
  65444. }
  65445. /**
  65446. * Class used to render controls with fluent desgin
  65447. */
  65448. export class FluentMaterial extends BABYLON.PushMaterial {
  65449. /**
  65450. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  65451. */
  65452. innerGlowColorIntensity: number;
  65453. /**
  65454. * Gets or sets the inner glow color (white by default)
  65455. */
  65456. innerGlowColor: BABYLON.Color3;
  65457. /**
  65458. * Gets or sets alpha value (default is 1.0)
  65459. */
  65460. alpha: number;
  65461. /**
  65462. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  65463. */
  65464. albedoColor: BABYLON.Color3;
  65465. /**
  65466. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  65467. */
  65468. renderBorders: boolean;
  65469. /**
  65470. * Gets or sets border width (default is 0.5)
  65471. */
  65472. borderWidth: number;
  65473. /**
  65474. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  65475. */
  65476. edgeSmoothingValue: number;
  65477. /**
  65478. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  65479. */
  65480. borderMinValue: number;
  65481. /**
  65482. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  65483. */
  65484. renderHoverLight: boolean;
  65485. /**
  65486. * Gets or sets the radius used to render the hover light (default is 1.0)
  65487. */
  65488. hoverRadius: number;
  65489. /**
  65490. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  65491. */
  65492. hoverColor: BABYLON.Color4;
  65493. /**
  65494. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  65495. */
  65496. hoverPosition: BABYLON.Vector3;
  65497. private _albedoTexture;
  65498. /** Gets or sets the texture to use for albedo color */
  65499. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65500. /**
  65501. * Creates a new Fluent material
  65502. * @param name defines the name of the material
  65503. * @param scene defines the hosting scene
  65504. */
  65505. constructor(name: string, scene: BABYLON.Scene);
  65506. needAlphaBlending(): boolean;
  65507. needAlphaTesting(): boolean;
  65508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65511. getActiveTextures(): BABYLON.BaseTexture[];
  65512. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65513. dispose(forceDisposeEffect?: boolean): void;
  65514. clone(name: string): FluentMaterial;
  65515. serialize(): any;
  65516. getClassName(): string;
  65517. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  65518. }
  65519. }
  65520. declare module BABYLON.GUI {
  65521. /**
  65522. * Class used to create a holographic button in 3D
  65523. */
  65524. export class HolographicButton extends Button3D {
  65525. private _backPlate;
  65526. private _textPlate;
  65527. private _frontPlate;
  65528. private _text;
  65529. private _imageUrl;
  65530. private _shareMaterials;
  65531. private _frontMaterial;
  65532. private _backMaterial;
  65533. private _plateMaterial;
  65534. private _pickedPointObserver;
  65535. private _tooltipFade;
  65536. private _tooltipTextBlock;
  65537. private _tooltipTexture;
  65538. private _tooltipMesh;
  65539. private _tooltipHoverObserver;
  65540. private _tooltipOutObserver;
  65541. private _disposeTooltip;
  65542. /**
  65543. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  65544. */
  65545. tooltipText: BABYLON.Nullable<string>;
  65546. /**
  65547. * Gets or sets text for the button
  65548. */
  65549. text: string;
  65550. /**
  65551. * Gets or sets the image url for the button
  65552. */
  65553. imageUrl: string;
  65554. /**
  65555. * Gets the back material used by this button
  65556. */
  65557. readonly backMaterial: FluentMaterial;
  65558. /**
  65559. * Gets the front material used by this button
  65560. */
  65561. readonly frontMaterial: FluentMaterial;
  65562. /**
  65563. * Gets the plate material used by this button
  65564. */
  65565. readonly plateMaterial: BABYLON.StandardMaterial;
  65566. /**
  65567. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  65568. */
  65569. readonly shareMaterials: boolean;
  65570. /**
  65571. * Creates a new button
  65572. * @param name defines the control name
  65573. */
  65574. constructor(name?: string, shareMaterials?: boolean);
  65575. protected _getTypeName(): string;
  65576. private _rebuildContent;
  65577. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65578. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  65579. private _createBackMaterial;
  65580. private _createFrontMaterial;
  65581. private _createPlateMaterial;
  65582. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  65583. /**
  65584. * Releases all associated resources
  65585. */
  65586. dispose(): void;
  65587. }
  65588. }
  65589. declare module BABYLON.GUI {
  65590. /**
  65591. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  65592. */
  65593. export class MeshButton3D extends Button3D {
  65594. /** @hidden */
  65595. protected _currentMesh: BABYLON.Mesh;
  65596. /**
  65597. * Creates a new 3D button based on a mesh
  65598. * @param mesh mesh to become a 3D button
  65599. * @param name defines the control name
  65600. */
  65601. constructor(mesh: BABYLON.Mesh, name?: string);
  65602. protected _getTypeName(): string;
  65603. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  65604. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  65605. }
  65606. }
  65607. declare module BABYLON.GUI {
  65608. /**
  65609. * Class used to create a container panel deployed on the surface of a plane
  65610. */
  65611. export class PlanePanel extends VolumeBasedPanel {
  65612. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65613. }
  65614. }
  65615. declare module BABYLON.GUI {
  65616. /**
  65617. * Class used to create a container panel where items get randomized planar mapping
  65618. */
  65619. export class ScatterPanel extends VolumeBasedPanel {
  65620. private _iteration;
  65621. /**
  65622. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  65623. */
  65624. iteration: BABYLON.float;
  65625. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65626. private _scatterMapping;
  65627. protected _finalProcessing(): void;
  65628. }
  65629. }
  65630. declare module BABYLON.GUI {
  65631. /**
  65632. * Class used to create a container panel deployed on the surface of a sphere
  65633. */
  65634. export class SpherePanel extends VolumeBasedPanel {
  65635. private _radius;
  65636. /**
  65637. * Gets or sets the radius of the sphere where to project controls (5 by default)
  65638. */
  65639. radius: BABYLON.float;
  65640. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  65641. private _sphericalMapping;
  65642. }
  65643. }
  65644. declare module BABYLON.GUI {
  65645. /**
  65646. * Class used to create a stack panel in 3D on XY plane
  65647. */
  65648. export class StackPanel3D extends Container3D {
  65649. private _isVertical;
  65650. /**
  65651. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  65652. */
  65653. isVertical: boolean;
  65654. /**
  65655. * Gets or sets the distance between elements
  65656. */
  65657. margin: number;
  65658. /**
  65659. * Creates new StackPanel
  65660. * @param isVertical
  65661. */
  65662. constructor(isVertical?: boolean);
  65663. protected _arrangeChildren(): void;
  65664. }
  65665. }
  65666. declare module BABYLON {
  65667. /**
  65668. * Mode that determines the coordinate system to use.
  65669. */
  65670. export enum GLTFLoaderCoordinateSystemMode {
  65671. /**
  65672. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  65673. */
  65674. AUTO = 0,
  65675. /**
  65676. * Sets the useRightHandedSystem flag on the scene.
  65677. */
  65678. FORCE_RIGHT_HANDED = 1
  65679. }
  65680. /**
  65681. * Mode that determines what animations will start.
  65682. */
  65683. export enum GLTFLoaderAnimationStartMode {
  65684. /**
  65685. * No animation will start.
  65686. */
  65687. NONE = 0,
  65688. /**
  65689. * The first animation will start.
  65690. */
  65691. FIRST = 1,
  65692. /**
  65693. * All animations will start.
  65694. */
  65695. ALL = 2
  65696. }
  65697. /**
  65698. * Interface that contains the data for the glTF asset.
  65699. */
  65700. export interface IGLTFLoaderData {
  65701. /**
  65702. * Object that represents the glTF JSON.
  65703. */
  65704. json: Object;
  65705. /**
  65706. * The BIN chunk of a binary glTF.
  65707. */
  65708. bin: Nullable<ArrayBufferView>;
  65709. }
  65710. /**
  65711. * Interface for extending the loader.
  65712. */
  65713. export interface IGLTFLoaderExtension {
  65714. /**
  65715. * The name of this extension.
  65716. */
  65717. readonly name: string;
  65718. /**
  65719. * Defines whether this extension is enabled.
  65720. */
  65721. enabled: boolean;
  65722. }
  65723. /**
  65724. * Loader state.
  65725. */
  65726. export enum GLTFLoaderState {
  65727. /**
  65728. * The asset is loading.
  65729. */
  65730. LOADING = 0,
  65731. /**
  65732. * The asset is ready for rendering.
  65733. */
  65734. READY = 1,
  65735. /**
  65736. * The asset is completely loaded.
  65737. */
  65738. COMPLETE = 2
  65739. }
  65740. /** @hidden */
  65741. export interface IGLTFLoader extends IDisposable {
  65742. readonly state: Nullable<GLTFLoaderState>;
  65743. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  65744. meshes: AbstractMesh[];
  65745. particleSystems: IParticleSystem[];
  65746. skeletons: Skeleton[];
  65747. animationGroups: AnimationGroup[];
  65748. }>;
  65749. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  65750. }
  65751. /**
  65752. * File loader for loading glTF files into a scene.
  65753. */
  65754. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65755. /** @hidden */
  65756. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65757. /** @hidden */
  65758. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  65759. /**
  65760. * Raised when the asset has been parsed
  65761. */
  65762. onParsedObservable: Observable<IGLTFLoaderData>;
  65763. private _onParsedObserver;
  65764. /**
  65765. * Raised when the asset has been parsed
  65766. */
  65767. onParsed: (loaderData: IGLTFLoaderData) => void;
  65768. /**
  65769. * 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.
  65770. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  65771. * Defaults to true.
  65772. * @hidden
  65773. */
  65774. static IncrementalLoading: boolean;
  65775. /**
  65776. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  65777. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  65778. * @hidden
  65779. */
  65780. static HomogeneousCoordinates: boolean;
  65781. /**
  65782. * The coordinate system mode. Defaults to AUTO.
  65783. */
  65784. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  65785. /**
  65786. * The animation start mode. Defaults to FIRST.
  65787. */
  65788. animationStartMode: GLTFLoaderAnimationStartMode;
  65789. /**
  65790. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  65791. */
  65792. compileMaterials: boolean;
  65793. /**
  65794. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  65795. */
  65796. useClipPlane: boolean;
  65797. /**
  65798. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  65799. */
  65800. compileShadowGenerators: boolean;
  65801. /**
  65802. * Defines if the Alpha blended materials are only applied as coverage.
  65803. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  65804. * If true, no extra effects are applied to transparent pixels.
  65805. */
  65806. transparencyAsCoverage: boolean;
  65807. /**
  65808. * Function called before loading a url referenced by the asset.
  65809. */
  65810. preprocessUrlAsync: (url: string) => Promise<string>;
  65811. /**
  65812. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65813. */
  65814. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  65815. private _onMeshLoadedObserver;
  65816. /**
  65817. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  65818. */
  65819. onMeshLoaded: (mesh: AbstractMesh) => void;
  65820. /**
  65821. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  65822. */
  65823. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  65824. private _onTextureLoadedObserver;
  65825. /**
  65826. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  65827. */
  65828. onTextureLoaded: (texture: BaseTexture) => void;
  65829. /**
  65830. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  65831. */
  65832. readonly onMaterialLoadedObservable: Observable<Material>;
  65833. private _onMaterialLoadedObserver;
  65834. /**
  65835. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  65836. */
  65837. onMaterialLoaded: (material: Material) => void;
  65838. /**
  65839. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  65840. */
  65841. readonly onCameraLoadedObservable: Observable<Camera>;
  65842. private _onCameraLoadedObserver;
  65843. /**
  65844. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  65845. */
  65846. onCameraLoaded: (camera: Camera) => void;
  65847. /**
  65848. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  65849. * For assets with LODs, raised when all of the LODs are complete.
  65850. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65851. */
  65852. readonly onCompleteObservable: Observable<void>;
  65853. private _onCompleteObserver;
  65854. /**
  65855. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  65856. * For assets with LODs, raised when all of the LODs are complete.
  65857. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  65858. */
  65859. onComplete: () => void;
  65860. /**
  65861. * Observable raised when an error occurs.
  65862. */
  65863. readonly onErrorObservable: Observable<any>;
  65864. private _onErrorObserver;
  65865. /**
  65866. * Callback raised when an error occurs.
  65867. */
  65868. onError: (reason: any) => void;
  65869. /**
  65870. * Observable raised after the loader is disposed.
  65871. */
  65872. readonly onDisposeObservable: Observable<void>;
  65873. private _onDisposeObserver;
  65874. /**
  65875. * Callback raised after the loader is disposed.
  65876. */
  65877. onDispose: () => void;
  65878. /**
  65879. * Observable raised after a loader extension is created.
  65880. * Set additional options for a loader extension in this event.
  65881. */
  65882. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  65883. private _onExtensionLoadedObserver;
  65884. /**
  65885. * Callback raised after a loader extension is created.
  65886. */
  65887. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  65888. /**
  65889. * Defines if the loader logging is enabled.
  65890. */
  65891. loggingEnabled: boolean;
  65892. /**
  65893. * Defines if the loader should capture performance counters.
  65894. */
  65895. capturePerformanceCounters: boolean;
  65896. /**
  65897. * Defines if the loader should validate the asset.
  65898. */
  65899. validate: boolean;
  65900. /**
  65901. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  65902. */
  65903. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  65904. private _onValidatedObserver;
  65905. /**
  65906. * Callback raised after a loader extension is created.
  65907. */
  65908. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  65909. private _loader;
  65910. /**
  65911. * Name of the loader ("gltf")
  65912. */
  65913. name: string;
  65914. /**
  65915. * Supported file extensions of the loader (.gltf, .glb)
  65916. */
  65917. extensions: ISceneLoaderPluginExtensions;
  65918. /**
  65919. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  65920. */
  65921. dispose(): void;
  65922. /** @hidden */
  65923. _clear(): void;
  65924. /**
  65925. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  65926. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65927. * @param scene the scene the meshes should be added to
  65928. * @param data the glTF data to load
  65929. * @param rootUrl root url to load from
  65930. * @param onProgress event that fires when loading progress has occured
  65931. * @param fileName Defines the name of the file to load
  65932. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65933. */
  65934. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65935. meshes: AbstractMesh[];
  65936. particleSystems: IParticleSystem[];
  65937. skeletons: Skeleton[];
  65938. animationGroups: AnimationGroup[];
  65939. }>;
  65940. /**
  65941. * Imports all objects from the loaded glTF data and adds them to the scene
  65942. * @param scene the scene the objects should be added to
  65943. * @param data the glTF data to load
  65944. * @param rootUrl root url to load from
  65945. * @param onProgress event that fires when loading progress has occured
  65946. * @param fileName Defines the name of the file to load
  65947. * @returns a promise which completes when objects have been loaded to the scene
  65948. */
  65949. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65950. /**
  65951. * Load into an asset container.
  65952. * @param scene The scene to load into
  65953. * @param data The data to import
  65954. * @param rootUrl The root url for scene and resources
  65955. * @param onProgress The callback when the load progresses
  65956. * @param fileName Defines the name of the file to load
  65957. * @returns The loaded asset container
  65958. */
  65959. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65960. /**
  65961. * If the data string can be loaded directly.
  65962. * @param data string contianing the file data
  65963. * @returns if the data can be loaded directly
  65964. */
  65965. canDirectLoad(data: string): boolean;
  65966. /**
  65967. * Rewrites a url by combining a root url and response url.
  65968. */
  65969. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  65970. /**
  65971. * Instantiates a glTF file loader plugin.
  65972. * @returns the created plugin
  65973. */
  65974. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  65975. /**
  65976. * The loader state or null if the loader is not active.
  65977. */
  65978. readonly loaderState: Nullable<GLTFLoaderState>;
  65979. /**
  65980. * Returns a promise that resolves when the asset is completely loaded.
  65981. * @returns a promise that resolves when the asset is completely loaded.
  65982. */
  65983. whenCompleteAsync(): Promise<void>;
  65984. private _parseAsync;
  65985. private _validateAsync;
  65986. private _getLoader;
  65987. private _unpackBinary;
  65988. private _unpackBinaryV1;
  65989. private _unpackBinaryV2;
  65990. private static _parseVersion;
  65991. private static _compareVersion;
  65992. private static _decodeBufferToText;
  65993. private static readonly _logSpaces;
  65994. private _logIndentLevel;
  65995. private _loggingEnabled;
  65996. /** @hidden */
  65997. _log: (message: string) => void;
  65998. /** @hidden */
  65999. _logOpen(message: string): void;
  66000. /** @hidden */
  66001. _logClose(): void;
  66002. private _logEnabled;
  66003. private _logDisabled;
  66004. private _capturePerformanceCounters;
  66005. /** @hidden */
  66006. _startPerformanceCounter: (counterName: string) => void;
  66007. /** @hidden */
  66008. _endPerformanceCounter: (counterName: string) => void;
  66009. private _startPerformanceCounterEnabled;
  66010. private _startPerformanceCounterDisabled;
  66011. private _endPerformanceCounterEnabled;
  66012. private _endPerformanceCounterDisabled;
  66013. }
  66014. }
  66015. declare module BABYLON.GLTF1 {
  66016. /**
  66017. * Enums
  66018. * @hidden
  66019. */
  66020. export enum EComponentType {
  66021. BYTE = 5120,
  66022. UNSIGNED_BYTE = 5121,
  66023. SHORT = 5122,
  66024. UNSIGNED_SHORT = 5123,
  66025. FLOAT = 5126
  66026. }
  66027. /** @hidden */
  66028. export enum EShaderType {
  66029. FRAGMENT = 35632,
  66030. VERTEX = 35633
  66031. }
  66032. /** @hidden */
  66033. export enum EParameterType {
  66034. BYTE = 5120,
  66035. UNSIGNED_BYTE = 5121,
  66036. SHORT = 5122,
  66037. UNSIGNED_SHORT = 5123,
  66038. INT = 5124,
  66039. UNSIGNED_INT = 5125,
  66040. FLOAT = 5126,
  66041. FLOAT_VEC2 = 35664,
  66042. FLOAT_VEC3 = 35665,
  66043. FLOAT_VEC4 = 35666,
  66044. INT_VEC2 = 35667,
  66045. INT_VEC3 = 35668,
  66046. INT_VEC4 = 35669,
  66047. BOOL = 35670,
  66048. BOOL_VEC2 = 35671,
  66049. BOOL_VEC3 = 35672,
  66050. BOOL_VEC4 = 35673,
  66051. FLOAT_MAT2 = 35674,
  66052. FLOAT_MAT3 = 35675,
  66053. FLOAT_MAT4 = 35676,
  66054. SAMPLER_2D = 35678
  66055. }
  66056. /** @hidden */
  66057. export enum ETextureWrapMode {
  66058. CLAMP_TO_EDGE = 33071,
  66059. MIRRORED_REPEAT = 33648,
  66060. REPEAT = 10497
  66061. }
  66062. /** @hidden */
  66063. export enum ETextureFilterType {
  66064. NEAREST = 9728,
  66065. LINEAR = 9728,
  66066. NEAREST_MIPMAP_NEAREST = 9984,
  66067. LINEAR_MIPMAP_NEAREST = 9985,
  66068. NEAREST_MIPMAP_LINEAR = 9986,
  66069. LINEAR_MIPMAP_LINEAR = 9987
  66070. }
  66071. /** @hidden */
  66072. export enum ETextureFormat {
  66073. ALPHA = 6406,
  66074. RGB = 6407,
  66075. RGBA = 6408,
  66076. LUMINANCE = 6409,
  66077. LUMINANCE_ALPHA = 6410
  66078. }
  66079. /** @hidden */
  66080. export enum ECullingType {
  66081. FRONT = 1028,
  66082. BACK = 1029,
  66083. FRONT_AND_BACK = 1032
  66084. }
  66085. /** @hidden */
  66086. export enum EBlendingFunction {
  66087. ZERO = 0,
  66088. ONE = 1,
  66089. SRC_COLOR = 768,
  66090. ONE_MINUS_SRC_COLOR = 769,
  66091. DST_COLOR = 774,
  66092. ONE_MINUS_DST_COLOR = 775,
  66093. SRC_ALPHA = 770,
  66094. ONE_MINUS_SRC_ALPHA = 771,
  66095. DST_ALPHA = 772,
  66096. ONE_MINUS_DST_ALPHA = 773,
  66097. CONSTANT_COLOR = 32769,
  66098. ONE_MINUS_CONSTANT_COLOR = 32770,
  66099. CONSTANT_ALPHA = 32771,
  66100. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66101. SRC_ALPHA_SATURATE = 776
  66102. }
  66103. /** @hidden */
  66104. export interface IGLTFProperty {
  66105. extensions?: {
  66106. [key: string]: any;
  66107. };
  66108. extras?: Object;
  66109. }
  66110. /** @hidden */
  66111. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66112. name?: string;
  66113. }
  66114. /** @hidden */
  66115. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66116. bufferView: string;
  66117. byteOffset: number;
  66118. byteStride: number;
  66119. count: number;
  66120. type: string;
  66121. componentType: EComponentType;
  66122. max?: number[];
  66123. min?: number[];
  66124. name?: string;
  66125. }
  66126. /** @hidden */
  66127. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66128. buffer: string;
  66129. byteOffset: number;
  66130. byteLength: number;
  66131. byteStride: number;
  66132. target?: number;
  66133. }
  66134. /** @hidden */
  66135. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66136. uri: string;
  66137. byteLength?: number;
  66138. type?: string;
  66139. }
  66140. /** @hidden */
  66141. export interface IGLTFShader extends IGLTFChildRootProperty {
  66142. uri: string;
  66143. type: EShaderType;
  66144. }
  66145. /** @hidden */
  66146. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66147. attributes: string[];
  66148. fragmentShader: string;
  66149. vertexShader: string;
  66150. }
  66151. /** @hidden */
  66152. export interface IGLTFTechniqueParameter {
  66153. type: number;
  66154. count?: number;
  66155. semantic?: string;
  66156. node?: string;
  66157. value?: number | boolean | string | Array<any>;
  66158. source?: string;
  66159. babylonValue?: any;
  66160. }
  66161. /** @hidden */
  66162. export interface IGLTFTechniqueCommonProfile {
  66163. lightingModel: string;
  66164. texcoordBindings: Object;
  66165. parameters?: Array<any>;
  66166. }
  66167. /** @hidden */
  66168. export interface IGLTFTechniqueStatesFunctions {
  66169. blendColor?: number[];
  66170. blendEquationSeparate?: number[];
  66171. blendFuncSeparate?: number[];
  66172. colorMask: boolean[];
  66173. cullFace: number[];
  66174. }
  66175. /** @hidden */
  66176. export interface IGLTFTechniqueStates {
  66177. enable: number[];
  66178. functions: IGLTFTechniqueStatesFunctions;
  66179. }
  66180. /** @hidden */
  66181. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66182. parameters: {
  66183. [key: string]: IGLTFTechniqueParameter;
  66184. };
  66185. program: string;
  66186. attributes: {
  66187. [key: string]: string;
  66188. };
  66189. uniforms: {
  66190. [key: string]: string;
  66191. };
  66192. states: IGLTFTechniqueStates;
  66193. }
  66194. /** @hidden */
  66195. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66196. technique?: string;
  66197. values: string[];
  66198. }
  66199. /** @hidden */
  66200. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66201. attributes: {
  66202. [key: string]: string;
  66203. };
  66204. indices: string;
  66205. material: string;
  66206. mode?: number;
  66207. }
  66208. /** @hidden */
  66209. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66210. primitives: IGLTFMeshPrimitive[];
  66211. }
  66212. /** @hidden */
  66213. export interface IGLTFImage extends IGLTFChildRootProperty {
  66214. uri: string;
  66215. }
  66216. /** @hidden */
  66217. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66218. magFilter?: number;
  66219. minFilter?: number;
  66220. wrapS?: number;
  66221. wrapT?: number;
  66222. }
  66223. /** @hidden */
  66224. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66225. sampler: string;
  66226. source: string;
  66227. format?: ETextureFormat;
  66228. internalFormat?: ETextureFormat;
  66229. target?: number;
  66230. type?: number;
  66231. babylonTexture?: Texture;
  66232. }
  66233. /** @hidden */
  66234. export interface IGLTFAmbienLight {
  66235. color?: number[];
  66236. }
  66237. /** @hidden */
  66238. export interface IGLTFDirectionalLight {
  66239. color?: number[];
  66240. }
  66241. /** @hidden */
  66242. export interface IGLTFPointLight {
  66243. color?: number[];
  66244. constantAttenuation?: number;
  66245. linearAttenuation?: number;
  66246. quadraticAttenuation?: number;
  66247. }
  66248. /** @hidden */
  66249. export interface IGLTFSpotLight {
  66250. color?: number[];
  66251. constantAttenuation?: number;
  66252. fallOfAngle?: number;
  66253. fallOffExponent?: number;
  66254. linearAttenuation?: number;
  66255. quadraticAttenuation?: number;
  66256. }
  66257. /** @hidden */
  66258. export interface IGLTFLight extends IGLTFChildRootProperty {
  66259. type: string;
  66260. }
  66261. /** @hidden */
  66262. export interface IGLTFCameraOrthographic {
  66263. xmag: number;
  66264. ymag: number;
  66265. zfar: number;
  66266. znear: number;
  66267. }
  66268. /** @hidden */
  66269. export interface IGLTFCameraPerspective {
  66270. aspectRatio: number;
  66271. yfov: number;
  66272. zfar: number;
  66273. znear: number;
  66274. }
  66275. /** @hidden */
  66276. export interface IGLTFCamera extends IGLTFChildRootProperty {
  66277. type: string;
  66278. }
  66279. /** @hidden */
  66280. export interface IGLTFAnimationChannelTarget {
  66281. id: string;
  66282. path: string;
  66283. }
  66284. /** @hidden */
  66285. export interface IGLTFAnimationChannel {
  66286. sampler: string;
  66287. target: IGLTFAnimationChannelTarget;
  66288. }
  66289. /** @hidden */
  66290. export interface IGLTFAnimationSampler {
  66291. input: string;
  66292. output: string;
  66293. interpolation?: string;
  66294. }
  66295. /** @hidden */
  66296. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  66297. channels?: IGLTFAnimationChannel[];
  66298. parameters?: {
  66299. [key: string]: string;
  66300. };
  66301. samplers?: {
  66302. [key: string]: IGLTFAnimationSampler;
  66303. };
  66304. }
  66305. /** @hidden */
  66306. export interface IGLTFNodeInstanceSkin {
  66307. skeletons: string[];
  66308. skin: string;
  66309. meshes: string[];
  66310. }
  66311. /** @hidden */
  66312. export interface IGLTFSkins extends IGLTFChildRootProperty {
  66313. bindShapeMatrix: number[];
  66314. inverseBindMatrices: string;
  66315. jointNames: string[];
  66316. babylonSkeleton?: Skeleton;
  66317. }
  66318. /** @hidden */
  66319. export interface IGLTFNode extends IGLTFChildRootProperty {
  66320. camera?: string;
  66321. children: string[];
  66322. skin?: string;
  66323. jointName?: string;
  66324. light?: string;
  66325. matrix: number[];
  66326. mesh?: string;
  66327. meshes?: string[];
  66328. rotation?: number[];
  66329. scale?: number[];
  66330. translation?: number[];
  66331. babylonNode?: Node;
  66332. }
  66333. /** @hidden */
  66334. export interface IGLTFScene extends IGLTFChildRootProperty {
  66335. nodes: string[];
  66336. }
  66337. /** @hidden */
  66338. export interface IGLTFRuntime {
  66339. extensions: {
  66340. [key: string]: any;
  66341. };
  66342. accessors: {
  66343. [key: string]: IGLTFAccessor;
  66344. };
  66345. buffers: {
  66346. [key: string]: IGLTFBuffer;
  66347. };
  66348. bufferViews: {
  66349. [key: string]: IGLTFBufferView;
  66350. };
  66351. meshes: {
  66352. [key: string]: IGLTFMesh;
  66353. };
  66354. lights: {
  66355. [key: string]: IGLTFLight;
  66356. };
  66357. cameras: {
  66358. [key: string]: IGLTFCamera;
  66359. };
  66360. nodes: {
  66361. [key: string]: IGLTFNode;
  66362. };
  66363. images: {
  66364. [key: string]: IGLTFImage;
  66365. };
  66366. textures: {
  66367. [key: string]: IGLTFTexture;
  66368. };
  66369. shaders: {
  66370. [key: string]: IGLTFShader;
  66371. };
  66372. programs: {
  66373. [key: string]: IGLTFProgram;
  66374. };
  66375. samplers: {
  66376. [key: string]: IGLTFSampler;
  66377. };
  66378. techniques: {
  66379. [key: string]: IGLTFTechnique;
  66380. };
  66381. materials: {
  66382. [key: string]: IGLTFMaterial;
  66383. };
  66384. animations: {
  66385. [key: string]: IGLTFAnimation;
  66386. };
  66387. skins: {
  66388. [key: string]: IGLTFSkins;
  66389. };
  66390. currentScene?: Object;
  66391. scenes: {
  66392. [key: string]: IGLTFScene;
  66393. };
  66394. extensionsUsed: string[];
  66395. extensionsRequired?: string[];
  66396. buffersCount: number;
  66397. shaderscount: number;
  66398. scene: Scene;
  66399. rootUrl: string;
  66400. loadedBufferCount: number;
  66401. loadedBufferViews: {
  66402. [name: string]: ArrayBufferView;
  66403. };
  66404. loadedShaderCount: number;
  66405. importOnlyMeshes: boolean;
  66406. importMeshesNames?: string[];
  66407. dummyNodes: Node[];
  66408. }
  66409. /** @hidden */
  66410. export interface INodeToRoot {
  66411. bone: Bone;
  66412. node: IGLTFNode;
  66413. id: string;
  66414. }
  66415. /** @hidden */
  66416. export interface IJointNode {
  66417. node: IGLTFNode;
  66418. id: string;
  66419. }
  66420. }
  66421. declare module BABYLON.GLTF1 {
  66422. /**
  66423. * Utils functions for GLTF
  66424. * @hidden
  66425. */
  66426. export class GLTFUtils {
  66427. /**
  66428. * Sets the given "parameter" matrix
  66429. * @param scene: the Scene object
  66430. * @param source: the source node where to pick the matrix
  66431. * @param parameter: the GLTF technique parameter
  66432. * @param uniformName: the name of the shader's uniform
  66433. * @param shaderMaterial: the shader material
  66434. */
  66435. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  66436. /**
  66437. * Sets the given "parameter" matrix
  66438. * @param shaderMaterial: the shader material
  66439. * @param uniform: the name of the shader's uniform
  66440. * @param value: the value of the uniform
  66441. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  66442. */
  66443. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  66444. /**
  66445. * Returns the wrap mode of the texture
  66446. * @param mode: the mode value
  66447. */
  66448. static GetWrapMode(mode: number): number;
  66449. /**
  66450. * Returns the byte stride giving an accessor
  66451. * @param accessor: the GLTF accessor objet
  66452. */
  66453. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  66454. /**
  66455. * Returns the texture filter mode giving a mode value
  66456. * @param mode: the filter mode value
  66457. */
  66458. static GetTextureFilterMode(mode: number): ETextureFilterType;
  66459. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  66460. /**
  66461. * Returns a buffer from its accessor
  66462. * @param gltfRuntime: the GLTF runtime
  66463. * @param accessor: the GLTF accessor
  66464. */
  66465. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  66466. /**
  66467. * Decodes a buffer view into a string
  66468. * @param view: the buffer view
  66469. */
  66470. static DecodeBufferToText(view: ArrayBufferView): string;
  66471. /**
  66472. * Returns the default material of gltf. Related to
  66473. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  66474. * @param scene: the Babylon.js scene
  66475. */
  66476. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  66477. private static _DefaultMaterial;
  66478. }
  66479. }
  66480. declare module BABYLON.GLTF1 {
  66481. /**
  66482. * Implementation of the base glTF spec
  66483. * @hidden
  66484. */
  66485. export class GLTFLoaderBase {
  66486. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  66487. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66488. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  66489. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66490. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  66491. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66492. }
  66493. /**
  66494. * glTF V1 Loader
  66495. * @hidden
  66496. */
  66497. export class GLTFLoader implements IGLTFLoader {
  66498. static Extensions: {
  66499. [name: string]: GLTFLoaderExtension;
  66500. };
  66501. static RegisterExtension(extension: GLTFLoaderExtension): void;
  66502. state: Nullable<GLTFLoaderState>;
  66503. dispose(): void;
  66504. private _importMeshAsync;
  66505. /**
  66506. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  66507. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66508. * @param scene the scene the meshes should be added to
  66509. * @param data gltf data containing information of the meshes in a loaded file
  66510. * @param rootUrl root url to load from
  66511. * @param onProgress event that fires when loading progress has occured
  66512. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66513. */
  66514. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  66515. meshes: AbstractMesh[];
  66516. particleSystems: IParticleSystem[];
  66517. skeletons: Skeleton[];
  66518. animationGroups: AnimationGroup[];
  66519. }>;
  66520. private _loadAsync;
  66521. /**
  66522. * Imports all objects from a loaded gltf file and adds them to the scene
  66523. * @param scene the scene the objects should be added to
  66524. * @param data gltf data containing information of the meshes in a loaded file
  66525. * @param rootUrl root url to load from
  66526. * @param onProgress event that fires when loading progress has occured
  66527. * @returns a promise which completes when objects have been loaded to the scene
  66528. */
  66529. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  66530. private _loadShadersAsync;
  66531. private _loadBuffersAsync;
  66532. private _createNodes;
  66533. }
  66534. /** @hidden */
  66535. export abstract class GLTFLoaderExtension {
  66536. private _name;
  66537. constructor(name: string);
  66538. readonly name: string;
  66539. /**
  66540. * Defines an override for loading the runtime
  66541. * Return true to stop further extensions from loading the runtime
  66542. */
  66543. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  66544. /**
  66545. * Defines an onverride for creating gltf runtime
  66546. * Return true to stop further extensions from creating the runtime
  66547. */
  66548. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  66549. /**
  66550. * Defines an override for loading buffers
  66551. * Return true to stop further extensions from loading this buffer
  66552. */
  66553. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  66554. /**
  66555. * Defines an override for loading texture buffers
  66556. * Return true to stop further extensions from loading this texture data
  66557. */
  66558. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66559. /**
  66560. * Defines an override for creating textures
  66561. * Return true to stop further extensions from loading this texture
  66562. */
  66563. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  66564. /**
  66565. * Defines an override for loading shader strings
  66566. * Return true to stop further extensions from loading this shader data
  66567. */
  66568. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66569. /**
  66570. * Defines an override for loading materials
  66571. * Return true to stop further extensions from loading this material
  66572. */
  66573. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66574. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  66575. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  66576. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  66577. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  66578. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  66579. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  66580. private static LoadTextureBufferAsync;
  66581. private static CreateTextureAsync;
  66582. private static ApplyExtensions;
  66583. }
  66584. }
  66585. declare module BABYLON.GLTF1 {
  66586. /** @hidden */
  66587. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  66588. private _bin;
  66589. constructor();
  66590. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  66591. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66592. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  66593. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  66594. }
  66595. }
  66596. declare module BABYLON.GLTF1 {
  66597. /** @hidden */
  66598. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  66599. constructor();
  66600. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  66601. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  66602. private _loadTexture;
  66603. }
  66604. }
  66605. declare module BABYLON.GLTF2.Loader {
  66606. /**
  66607. * Loader interface with an index field.
  66608. */
  66609. export interface IArrayItem {
  66610. /**
  66611. * The index of this item in the array.
  66612. */
  66613. index: number;
  66614. }
  66615. /**
  66616. * Loader interface with additional members.
  66617. */
  66618. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  66619. /** @hidden */
  66620. _data?: Promise<ArrayBufferView>;
  66621. /** @hidden */
  66622. _babylonVertexBuffer?: Promise<VertexBuffer>;
  66623. }
  66624. /**
  66625. * Loader interface with additional members.
  66626. */
  66627. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  66628. }
  66629. /** @hidden */
  66630. export interface _IAnimationSamplerData {
  66631. input: Float32Array;
  66632. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  66633. output: Float32Array;
  66634. }
  66635. /**
  66636. * Loader interface with additional members.
  66637. */
  66638. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  66639. /** @hidden */
  66640. _data?: Promise<_IAnimationSamplerData>;
  66641. }
  66642. /**
  66643. * Loader interface with additional members.
  66644. */
  66645. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  66646. channels: IAnimationChannel[];
  66647. samplers: IAnimationSampler[];
  66648. /** @hidden */
  66649. _babylonAnimationGroup?: AnimationGroup;
  66650. }
  66651. /**
  66652. * Loader interface with additional members.
  66653. */
  66654. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  66655. /** @hidden */
  66656. _data?: Promise<ArrayBufferView>;
  66657. }
  66658. /**
  66659. * Loader interface with additional members.
  66660. */
  66661. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  66662. /** @hidden */
  66663. _data?: Promise<ArrayBufferView>;
  66664. /** @hidden */
  66665. _babylonBuffer?: Promise<Buffer>;
  66666. }
  66667. /**
  66668. * Loader interface with additional members.
  66669. */
  66670. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  66671. }
  66672. /**
  66673. * Loader interface with additional members.
  66674. */
  66675. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  66676. /** @hidden */
  66677. _data?: Promise<ArrayBufferView>;
  66678. }
  66679. /**
  66680. * Loader interface with additional members.
  66681. */
  66682. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  66683. }
  66684. /**
  66685. * Loader interface with additional members.
  66686. */
  66687. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  66688. }
  66689. /**
  66690. * Loader interface with additional members.
  66691. */
  66692. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  66693. baseColorTexture?: ITextureInfo;
  66694. metallicRoughnessTexture?: ITextureInfo;
  66695. }
  66696. /**
  66697. * Loader interface with additional members.
  66698. */
  66699. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  66700. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66701. normalTexture?: IMaterialNormalTextureInfo;
  66702. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66703. emissiveTexture?: ITextureInfo;
  66704. /** @hidden */
  66705. _data?: {
  66706. [babylonDrawMode: number]: {
  66707. babylonMaterial: Material;
  66708. babylonMeshes: AbstractMesh[];
  66709. promise: Promise<void>;
  66710. };
  66711. };
  66712. }
  66713. /**
  66714. * Loader interface with additional members.
  66715. */
  66716. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  66717. primitives: IMeshPrimitive[];
  66718. }
  66719. /**
  66720. * Loader interface with additional members.
  66721. */
  66722. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  66723. /** @hidden */
  66724. _instanceData?: {
  66725. babylonSourceMesh: Mesh;
  66726. promise: Promise<any>;
  66727. };
  66728. }
  66729. /**
  66730. * Loader interface with additional members.
  66731. */
  66732. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  66733. /**
  66734. * The parent glTF node.
  66735. */
  66736. parent?: INode;
  66737. /** @hidden */
  66738. _babylonTransformNode?: TransformNode;
  66739. /** @hidden */
  66740. _primitiveBabylonMeshes?: AbstractMesh[];
  66741. /** @hidden */
  66742. _babylonBones?: Bone[];
  66743. /** @hidden */
  66744. _numMorphTargets?: number;
  66745. }
  66746. /** @hidden */
  66747. export interface _ISamplerData {
  66748. noMipMaps: boolean;
  66749. samplingMode: number;
  66750. wrapU: number;
  66751. wrapV: number;
  66752. }
  66753. /**
  66754. * Loader interface with additional members.
  66755. */
  66756. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  66757. /** @hidden */
  66758. _data?: _ISamplerData;
  66759. }
  66760. /**
  66761. * Loader interface with additional members.
  66762. */
  66763. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  66764. }
  66765. /**
  66766. * Loader interface with additional members.
  66767. */
  66768. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  66769. /** @hidden */
  66770. _data?: {
  66771. babylonSkeleton: Skeleton;
  66772. promise: Promise<void>;
  66773. };
  66774. }
  66775. /**
  66776. * Loader interface with additional members.
  66777. */
  66778. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  66779. }
  66780. /**
  66781. * Loader interface with additional members.
  66782. */
  66783. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  66784. }
  66785. /**
  66786. * Loader interface with additional members.
  66787. */
  66788. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  66789. accessors?: IAccessor[];
  66790. animations?: IAnimation[];
  66791. buffers?: IBuffer[];
  66792. bufferViews?: IBufferView[];
  66793. cameras?: ICamera[];
  66794. images?: IImage[];
  66795. materials?: IMaterial[];
  66796. meshes?: IMesh[];
  66797. nodes?: INode[];
  66798. samplers?: ISampler[];
  66799. scenes?: IScene[];
  66800. skins?: ISkin[];
  66801. textures?: ITexture[];
  66802. }
  66803. }
  66804. declare module BABYLON.GLTF2 {
  66805. /**
  66806. * Interface for a glTF loader extension.
  66807. */
  66808. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  66809. /**
  66810. * Called after the loader state changes to LOADING.
  66811. */
  66812. onLoading?(): void;
  66813. /**
  66814. * Called after the loader state changes to READY.
  66815. */
  66816. onReady?(): void;
  66817. /**
  66818. * Define this method to modify the default behavior when loading scenes.
  66819. * @param context The context when loading the asset
  66820. * @param scene The glTF scene property
  66821. * @returns A promise that resolves when the load is complete or null if not handled
  66822. */
  66823. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  66824. /**
  66825. * Define this method to modify the default behavior when loading nodes.
  66826. * @param context The context when loading the asset
  66827. * @param node The glTF node property
  66828. * @param assign A function called synchronously after parsing the glTF properties
  66829. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  66830. */
  66831. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66832. /**
  66833. * Define this method to modify the default behavior when loading cameras.
  66834. * @param context The context when loading the asset
  66835. * @param camera The glTF camera property
  66836. * @param assign A function called synchronously after parsing the glTF properties
  66837. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  66838. */
  66839. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66840. /**
  66841. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  66842. * @param context The context when loading the asset
  66843. * @param primitive The glTF mesh primitive property
  66844. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  66845. */
  66846. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  66847. /**
  66848. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  66849. * @param context The context when loading the asset
  66850. * @param name The mesh name when loading the asset
  66851. * @param node The glTF node when loading the asset
  66852. * @param mesh The glTF mesh when loading the asset
  66853. * @param primitive The glTF mesh primitive property
  66854. * @param assign A function called synchronously after parsing the glTF properties
  66855. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  66856. */
  66857. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  66858. /**
  66859. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  66860. * @param context The context when loading the asset
  66861. * @param material The glTF material property
  66862. * @param assign A function called synchronously after parsing the glTF properties
  66863. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  66864. */
  66865. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66866. /**
  66867. * Define this method to modify the default behavior when creating materials.
  66868. * @param context The context when loading the asset
  66869. * @param material The glTF material property
  66870. * @param babylonDrawMode The draw mode for the Babylon material
  66871. * @returns The Babylon material or null if not handled
  66872. */
  66873. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66874. /**
  66875. * Define this method to modify the default behavior when loading material properties.
  66876. * @param context The context when loading the asset
  66877. * @param material The glTF material property
  66878. * @param babylonMaterial The Babylon material
  66879. * @returns A promise that resolves when the load is complete or null if not handled
  66880. */
  66881. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66882. /**
  66883. * Define this method to modify the default behavior when loading texture infos.
  66884. * @param context The context when loading the asset
  66885. * @param textureInfo The glTF texture info property
  66886. * @param assign A function called synchronously after parsing the glTF properties
  66887. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  66888. */
  66889. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  66890. /**
  66891. * Define this method to modify the default behavior when loading animations.
  66892. * @param context The context when loading the asset
  66893. * @param animation The glTF animation property
  66894. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  66895. */
  66896. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66897. /**
  66898. * @hidden Define this method to modify the default behavior when loading skins.
  66899. * @param context The context when loading the asset
  66900. * @param node The glTF node property
  66901. * @param skin The glTF skin property
  66902. * @returns A promise that resolves when the load is complete or null if not handled
  66903. */
  66904. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  66905. /**
  66906. * @hidden Define this method to modify the default behavior when loading uris.
  66907. * @param context The context when loading the asset
  66908. * @param property The glTF property associated with the uri
  66909. * @param uri The uri to load
  66910. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  66911. */
  66912. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66913. }
  66914. }
  66915. declare module BABYLON.GLTF2 {
  66916. /**
  66917. * Helper class for working with arrays when loading the glTF asset
  66918. */
  66919. export class ArrayItem {
  66920. /**
  66921. * Gets an item from the given array.
  66922. * @param context The context when loading the asset
  66923. * @param array The array to get the item from
  66924. * @param index The index to the array
  66925. * @returns The array item
  66926. */
  66927. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  66928. /**
  66929. * Assign an `index` field to each item of the given array.
  66930. * @param array The array of items
  66931. */
  66932. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  66933. }
  66934. /**
  66935. * The glTF 2.0 loader
  66936. */
  66937. export class GLTFLoader implements IGLTFLoader {
  66938. /** @hidden */
  66939. _completePromises: Promise<any>[];
  66940. private _disposed;
  66941. private _parent;
  66942. private _state;
  66943. private _extensions;
  66944. private _rootUrl;
  66945. private _fileName;
  66946. private _uniqueRootUrl;
  66947. private _gltf;
  66948. private _babylonScene;
  66949. private _rootBabylonMesh;
  66950. private _defaultBabylonMaterialData;
  66951. private _progressCallback?;
  66952. private _requests;
  66953. private static readonly _DefaultSampler;
  66954. private static _ExtensionNames;
  66955. private static _ExtensionFactories;
  66956. /**
  66957. * Registers a loader extension.
  66958. * @param name The name of the loader extension.
  66959. * @param factory The factory function that creates the loader extension.
  66960. */
  66961. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  66962. /**
  66963. * Unregisters a loader extension.
  66964. * @param name The name of the loader extenion.
  66965. * @returns A boolean indicating whether the extension has been unregistered
  66966. */
  66967. static UnregisterExtension(name: string): boolean;
  66968. /**
  66969. * Gets the loader state.
  66970. */
  66971. readonly state: Nullable<GLTFLoaderState>;
  66972. /**
  66973. * The glTF object parsed from the JSON.
  66974. */
  66975. readonly gltf: IGLTF;
  66976. /**
  66977. * The Babylon scene when loading the asset.
  66978. */
  66979. readonly babylonScene: Scene;
  66980. /**
  66981. * The root Babylon mesh when loading the asset.
  66982. */
  66983. readonly rootBabylonMesh: Mesh;
  66984. /** @hidden */
  66985. constructor(parent: GLTFFileLoader);
  66986. /** @hidden */
  66987. dispose(): void;
  66988. /** @hidden */
  66989. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66990. meshes: AbstractMesh[];
  66991. particleSystems: IParticleSystem[];
  66992. skeletons: Skeleton[];
  66993. animationGroups: AnimationGroup[];
  66994. }>;
  66995. /** @hidden */
  66996. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66997. private _loadAsync;
  66998. private _loadData;
  66999. private _setupData;
  67000. private _loadExtensions;
  67001. private _checkExtensions;
  67002. private _setState;
  67003. private _createRootNode;
  67004. /**
  67005. * Loads a glTF scene.
  67006. * @param context The context when loading the asset
  67007. * @param scene The glTF scene property
  67008. * @returns A promise that resolves when the load is complete
  67009. */
  67010. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67011. private _forEachPrimitive;
  67012. private _getMeshes;
  67013. private _getSkeletons;
  67014. private _getAnimationGroups;
  67015. private _startAnimations;
  67016. /**
  67017. * Loads a glTF node.
  67018. * @param context The context when loading the asset
  67019. * @param node The glTF node property
  67020. * @param assign A function called synchronously after parsing the glTF properties
  67021. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67022. */
  67023. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67024. private _loadMeshAsync;
  67025. /**
  67026. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67027. * @param context The context when loading the asset
  67028. * @param name The mesh name when loading the asset
  67029. * @param node The glTF node when loading the asset
  67030. * @param mesh The glTF mesh when loading the asset
  67031. * @param primitive The glTF mesh primitive property
  67032. * @param assign A function called synchronously after parsing the glTF properties
  67033. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67034. */
  67035. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67036. private _loadVertexDataAsync;
  67037. private _createMorphTargets;
  67038. private _loadMorphTargetsAsync;
  67039. private _loadMorphTargetVertexDataAsync;
  67040. private static _LoadTransform;
  67041. private _loadSkinAsync;
  67042. private _loadBones;
  67043. private _loadBone;
  67044. private _loadSkinInverseBindMatricesDataAsync;
  67045. private _updateBoneMatrices;
  67046. private _getNodeMatrix;
  67047. /**
  67048. * Loads a glTF camera.
  67049. * @param context The context when loading the asset
  67050. * @param camera The glTF camera property
  67051. * @param assign A function called synchronously after parsing the glTF properties
  67052. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67053. */
  67054. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67055. private _loadAnimationsAsync;
  67056. /**
  67057. * Loads a glTF animation.
  67058. * @param context The context when loading the asset
  67059. * @param animation The glTF animation property
  67060. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67061. */
  67062. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67063. /**
  67064. * @hidden Loads a glTF animation channel.
  67065. * @param context The context when loading the asset
  67066. * @param animationContext The context of the animation when loading the asset
  67067. * @param animation The glTF animation property
  67068. * @param channel The glTF animation channel property
  67069. * @param babylonAnimationGroup The babylon animation group property
  67070. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67071. * @returns A void promise when the channel load is complete
  67072. */
  67073. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67074. private _loadAnimationSamplerAsync;
  67075. private _loadBufferAsync;
  67076. /**
  67077. * Loads a glTF buffer view.
  67078. * @param context The context when loading the asset
  67079. * @param bufferView The glTF buffer view property
  67080. * @returns A promise that resolves with the loaded data when the load is complete
  67081. */
  67082. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67083. private _loadAccessorAsync;
  67084. private _loadFloatAccessorAsync;
  67085. private _loadIndicesAccessorAsync;
  67086. private _loadVertexBufferViewAsync;
  67087. private _loadVertexAccessorAsync;
  67088. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67089. /** @hidden */
  67090. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67091. private _createDefaultMaterial;
  67092. /**
  67093. * Creates a Babylon material from a glTF material.
  67094. * @param context The context when loading the asset
  67095. * @param material The glTF material property
  67096. * @param babylonDrawMode The draw mode for the Babylon material
  67097. * @returns The Babylon material
  67098. */
  67099. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67100. /**
  67101. * Loads properties from a glTF material into a Babylon material.
  67102. * @param context The context when loading the asset
  67103. * @param material The glTF material property
  67104. * @param babylonMaterial The Babylon material
  67105. * @returns A promise that resolves when the load is complete
  67106. */
  67107. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67108. /**
  67109. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67110. * @param context The context when loading the asset
  67111. * @param material The glTF material property
  67112. * @param babylonMaterial The Babylon material
  67113. * @returns A promise that resolves when the load is complete
  67114. */
  67115. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67116. /**
  67117. * Loads the alpha properties from a glTF material into a Babylon material.
  67118. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67119. * @param context The context when loading the asset
  67120. * @param material The glTF material property
  67121. * @param babylonMaterial The Babylon material
  67122. */
  67123. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67124. /**
  67125. * Loads a glTF texture info.
  67126. * @param context The context when loading the asset
  67127. * @param textureInfo The glTF texture info property
  67128. * @param assign A function called synchronously after parsing the glTF properties
  67129. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67130. */
  67131. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67132. private _loadTextureAsync;
  67133. private _loadSampler;
  67134. /**
  67135. * Loads a glTF image.
  67136. * @param context The context when loading the asset
  67137. * @param image The glTF image property
  67138. * @returns A promise that resolves with the loaded data when the load is complete
  67139. */
  67140. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67141. /**
  67142. * Loads a glTF uri.
  67143. * @param context The context when loading the asset
  67144. * @param property The glTF property associated with the uri
  67145. * @param uri The base64 or relative uri
  67146. * @returns A promise that resolves with the loaded data when the load is complete
  67147. */
  67148. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67149. private _onProgress;
  67150. /**
  67151. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67152. * @param babylonObject the Babylon object with metadata
  67153. * @param pointer the JSON pointer
  67154. */
  67155. static AddPointerMetadata(babylonObject: {
  67156. metadata: any;
  67157. }, pointer: string): void;
  67158. private static _GetTextureWrapMode;
  67159. private static _GetTextureSamplingMode;
  67160. private static _GetTypedArrayConstructor;
  67161. private static _GetTypedArray;
  67162. private static _GetNumComponents;
  67163. private static _ValidateUri;
  67164. private static _GetDrawMode;
  67165. private _compileMaterialsAsync;
  67166. private _compileShadowGeneratorsAsync;
  67167. private _forEachExtensions;
  67168. private _applyExtensions;
  67169. private _extensionsOnLoading;
  67170. private _extensionsOnReady;
  67171. private _extensionsLoadSceneAsync;
  67172. private _extensionsLoadNodeAsync;
  67173. private _extensionsLoadCameraAsync;
  67174. private _extensionsLoadVertexDataAsync;
  67175. private _extensionsLoadMeshPrimitiveAsync;
  67176. private _extensionsLoadMaterialAsync;
  67177. private _extensionsCreateMaterial;
  67178. private _extensionsLoadMaterialPropertiesAsync;
  67179. private _extensionsLoadTextureInfoAsync;
  67180. private _extensionsLoadAnimationAsync;
  67181. private _extensionsLoadSkinAsync;
  67182. private _extensionsLoadUriAsync;
  67183. /**
  67184. * Helper method called by a loader extension to load an glTF extension.
  67185. * @param context The context when loading the asset
  67186. * @param property The glTF property to load the extension from
  67187. * @param extensionName The name of the extension to load
  67188. * @param actionAsync The action to run
  67189. * @returns The promise returned by actionAsync or null if the extension does not exist
  67190. */
  67191. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67192. /**
  67193. * Helper method called by a loader extension to load a glTF extra.
  67194. * @param context The context when loading the asset
  67195. * @param property The glTF property to load the extra from
  67196. * @param extensionName The name of the extension to load
  67197. * @param actionAsync The action to run
  67198. * @returns The promise returned by actionAsync or null if the extra does not exist
  67199. */
  67200. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67201. /**
  67202. * Increments the indentation level and logs a message.
  67203. * @param message The message to log
  67204. */
  67205. logOpen(message: string): void;
  67206. /**
  67207. * Decrements the indentation level.
  67208. */
  67209. logClose(): void;
  67210. /**
  67211. * Logs a message
  67212. * @param message The message to log
  67213. */
  67214. log(message: string): void;
  67215. /**
  67216. * Starts a performance counter.
  67217. * @param counterName The name of the performance counter
  67218. */
  67219. startPerformanceCounter(counterName: string): void;
  67220. /**
  67221. * Ends a performance counter.
  67222. * @param counterName The name of the performance counter
  67223. */
  67224. endPerformanceCounter(counterName: string): void;
  67225. }
  67226. }
  67227. declare module BABYLON.GLTF2.Loader.Extensions {
  67228. /**
  67229. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67230. */
  67231. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67232. /** The name of this extension. */
  67233. readonly name: string;
  67234. /** Defines whether this extension is enabled. */
  67235. enabled: boolean;
  67236. private _loader;
  67237. private _lights?;
  67238. /** @hidden */
  67239. constructor(loader: GLTFLoader);
  67240. /** @hidden */
  67241. dispose(): void;
  67242. /** @hidden */
  67243. onLoading(): void;
  67244. /** @hidden */
  67245. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67246. private _loadLightAsync;
  67247. }
  67248. }
  67249. declare module BABYLON.GLTF2.Loader.Extensions {
  67250. /**
  67251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67252. */
  67253. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67254. /** The name of this extension. */
  67255. readonly name: string;
  67256. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67257. dracoCompression?: DracoCompression;
  67258. /** Defines whether this extension is enabled. */
  67259. enabled: boolean;
  67260. private _loader;
  67261. /** @hidden */
  67262. constructor(loader: GLTFLoader);
  67263. /** @hidden */
  67264. dispose(): void;
  67265. /** @hidden */
  67266. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67267. }
  67268. }
  67269. declare module BABYLON.GLTF2.Loader.Extensions {
  67270. /**
  67271. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67272. */
  67273. export class KHR_lights implements IGLTFLoaderExtension {
  67274. /** The name of this extension. */
  67275. readonly name: string;
  67276. /** Defines whether this extension is enabled. */
  67277. enabled: boolean;
  67278. private _loader;
  67279. private _lights?;
  67280. /** @hidden */
  67281. constructor(loader: GLTFLoader);
  67282. /** @hidden */
  67283. dispose(): void;
  67284. /** @hidden */
  67285. onLoading(): void;
  67286. /** @hidden */
  67287. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67288. }
  67289. }
  67290. declare module BABYLON.GLTF2.Loader.Extensions {
  67291. /**
  67292. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67293. */
  67294. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67295. /** The name of this extension. */
  67296. readonly name: string;
  67297. /** Defines whether this extension is enabled. */
  67298. enabled: boolean;
  67299. private _loader;
  67300. /** @hidden */
  67301. constructor(loader: GLTFLoader);
  67302. /** @hidden */
  67303. dispose(): void;
  67304. /** @hidden */
  67305. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67306. private _loadSpecularGlossinessPropertiesAsync;
  67307. }
  67308. }
  67309. declare module BABYLON.GLTF2.Loader.Extensions {
  67310. /**
  67311. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  67312. */
  67313. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  67314. /** The name of this extension. */
  67315. readonly name: string;
  67316. /** Defines whether this extension is enabled. */
  67317. enabled: boolean;
  67318. private _loader;
  67319. /** @hidden */
  67320. constructor(loader: GLTFLoader);
  67321. /** @hidden */
  67322. dispose(): void;
  67323. /** @hidden */
  67324. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67325. private _loadUnlitPropertiesAsync;
  67326. }
  67327. }
  67328. declare module BABYLON.GLTF2.Loader.Extensions {
  67329. /**
  67330. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  67331. */
  67332. export class KHR_texture_transform implements IGLTFLoaderExtension {
  67333. /** The name of this extension. */
  67334. readonly name: string;
  67335. /** Defines whether this extension is enabled. */
  67336. enabled: boolean;
  67337. private _loader;
  67338. /** @hidden */
  67339. constructor(loader: GLTFLoader);
  67340. /** @hidden */
  67341. dispose(): void;
  67342. /** @hidden */
  67343. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67344. }
  67345. }
  67346. declare module BABYLON.GLTF2.Loader.Extensions {
  67347. /**
  67348. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  67349. */
  67350. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  67351. /** The name of this extension. */
  67352. readonly name: string;
  67353. /** Defines whether this extension is enabled. */
  67354. enabled: boolean;
  67355. private _loader;
  67356. private _clips;
  67357. private _emitters;
  67358. /** @hidden */
  67359. constructor(loader: GLTFLoader);
  67360. /** @hidden */
  67361. dispose(): void;
  67362. /** @hidden */
  67363. onLoading(): void;
  67364. /** @hidden */
  67365. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67366. /** @hidden */
  67367. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67368. /** @hidden */
  67369. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67370. private _loadClipAsync;
  67371. private _loadEmitterAsync;
  67372. private _getEventAction;
  67373. private _loadAnimationEventAsync;
  67374. }
  67375. }
  67376. declare module BABYLON.GLTF2.Loader.Extensions {
  67377. /**
  67378. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  67379. */
  67380. export class MSFT_lod implements IGLTFLoaderExtension {
  67381. /** The name of this extension. */
  67382. readonly name: string;
  67383. /** Defines whether this extension is enabled. */
  67384. enabled: boolean;
  67385. /**
  67386. * Maximum number of LODs to load, starting from the lowest LOD.
  67387. */
  67388. maxLODsToLoad: number;
  67389. /**
  67390. * Observable raised when all node LODs of one level are loaded.
  67391. * The event data is the index of the loaded LOD starting from zero.
  67392. * Dispose the loader to cancel the loading of the next level of LODs.
  67393. */
  67394. onNodeLODsLoadedObservable: Observable<number>;
  67395. /**
  67396. * Observable raised when all material LODs of one level are loaded.
  67397. * The event data is the index of the loaded LOD starting from zero.
  67398. * Dispose the loader to cancel the loading of the next level of LODs.
  67399. */
  67400. onMaterialLODsLoadedObservable: Observable<number>;
  67401. private _loader;
  67402. private _nodeIndexLOD;
  67403. private _nodeSignalLODs;
  67404. private _nodePromiseLODs;
  67405. private _materialIndexLOD;
  67406. private _materialSignalLODs;
  67407. private _materialPromiseLODs;
  67408. /** @hidden */
  67409. constructor(loader: GLTFLoader);
  67410. /** @hidden */
  67411. dispose(): void;
  67412. /** @hidden */
  67413. onReady(): void;
  67414. /** @hidden */
  67415. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67416. /** @hidden */
  67417. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67418. /** @hidden */
  67419. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67420. /**
  67421. * Gets an array of LOD properties from lowest to highest.
  67422. */
  67423. private _getLODs;
  67424. private _disposeUnusedMaterials;
  67425. }
  67426. }
  67427. declare module BABYLON.GLTF2.Loader.Extensions {
  67428. /** @hidden */
  67429. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  67430. readonly name: string;
  67431. enabled: boolean;
  67432. private _loader;
  67433. constructor(loader: GLTFLoader);
  67434. dispose(): void;
  67435. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67436. }
  67437. }
  67438. declare module BABYLON.GLTF2.Loader.Extensions {
  67439. /** @hidden */
  67440. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  67441. readonly name: string;
  67442. enabled: boolean;
  67443. private _loader;
  67444. constructor(loader: GLTFLoader);
  67445. dispose(): void;
  67446. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67447. }
  67448. }
  67449. declare module BABYLON.GLTF2.Loader.Extensions {
  67450. /**
  67451. * Store glTF extras (if present) in BJS objects' metadata
  67452. */
  67453. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  67454. /** The name of this extension. */
  67455. readonly name: string;
  67456. /** Defines whether this extension is enabled. */
  67457. enabled: boolean;
  67458. private _loader;
  67459. private _assignExtras;
  67460. /** @hidden */
  67461. constructor(loader: GLTFLoader);
  67462. /** @hidden */
  67463. dispose(): void;
  67464. /** @hidden */
  67465. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67466. /** @hidden */
  67467. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67468. /** @hidden */
  67469. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67470. }
  67471. }
  67472. declare module BABYLON {
  67473. /**
  67474. * Class reading and parsing the MTL file bundled with the obj file.
  67475. */
  67476. export class MTLFileLoader {
  67477. /**
  67478. * All material loaded from the mtl will be set here
  67479. */
  67480. materials: StandardMaterial[];
  67481. /**
  67482. * This function will read the mtl file and create each material described inside
  67483. * This function could be improve by adding :
  67484. * -some component missing (Ni, Tf...)
  67485. * -including the specific options available
  67486. *
  67487. * @param scene defines the scene the material will be created in
  67488. * @param data defines the mtl data to parse
  67489. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  67490. */
  67491. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  67492. /**
  67493. * Gets the texture for the material.
  67494. *
  67495. * If the material is imported from input file,
  67496. * We sanitize the url to ensure it takes the textre from aside the material.
  67497. *
  67498. * @param rootUrl The root url to load from
  67499. * @param value The value stored in the mtl
  67500. * @return The Texture
  67501. */
  67502. private static _getTexture;
  67503. }
  67504. /**
  67505. * Options for loading OBJ/MTL files
  67506. */
  67507. type MeshLoadOptions = {
  67508. /**
  67509. * Defines if UVs are optimized by default during load.
  67510. */
  67511. OptimizeWithUV: boolean;
  67512. /**
  67513. * Defines custom scaling of UV coordinates of loaded meshes.
  67514. */
  67515. UVScaling: Vector2;
  67516. /**
  67517. * Invert model on y-axis (does a model scaling inversion)
  67518. */
  67519. InvertY: boolean;
  67520. /**
  67521. * Invert Y-Axis of referenced textures on load
  67522. */
  67523. InvertTextureY: boolean;
  67524. /**
  67525. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67526. */
  67527. ImportVertexColors: boolean;
  67528. /**
  67529. * Compute the normals for the model, even if normals are present in the file.
  67530. */
  67531. ComputeNormals: boolean;
  67532. /**
  67533. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67534. */
  67535. SkipMaterials: boolean;
  67536. /**
  67537. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67538. */
  67539. MaterialLoadingFailsSilently: boolean;
  67540. };
  67541. /**
  67542. * OBJ file type loader.
  67543. * This is a babylon scene loader plugin.
  67544. */
  67545. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67546. /**
  67547. * Defines if UVs are optimized by default during load.
  67548. */
  67549. static OPTIMIZE_WITH_UV: boolean;
  67550. /**
  67551. * Invert model on y-axis (does a model scaling inversion)
  67552. */
  67553. static INVERT_Y: boolean;
  67554. /**
  67555. * Invert Y-Axis of referenced textures on load
  67556. */
  67557. static INVERT_TEXTURE_Y: boolean;
  67558. /**
  67559. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  67560. */
  67561. static IMPORT_VERTEX_COLORS: boolean;
  67562. /**
  67563. * Compute the normals for the model, even if normals are present in the file.
  67564. */
  67565. static COMPUTE_NORMALS: boolean;
  67566. /**
  67567. * Defines custom scaling of UV coordinates of loaded meshes.
  67568. */
  67569. static UV_SCALING: Vector2;
  67570. /**
  67571. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  67572. */
  67573. static SKIP_MATERIALS: boolean;
  67574. /**
  67575. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  67576. *
  67577. * Defaults to true for backwards compatibility.
  67578. */
  67579. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  67580. /**
  67581. * Defines the name of the plugin.
  67582. */
  67583. name: string;
  67584. /**
  67585. * Defines the extension the plugin is able to load.
  67586. */
  67587. extensions: string;
  67588. /** @hidden */
  67589. obj: RegExp;
  67590. /** @hidden */
  67591. group: RegExp;
  67592. /** @hidden */
  67593. mtllib: RegExp;
  67594. /** @hidden */
  67595. usemtl: RegExp;
  67596. /** @hidden */
  67597. smooth: RegExp;
  67598. /** @hidden */
  67599. vertexPattern: RegExp;
  67600. /** @hidden */
  67601. normalPattern: RegExp;
  67602. /** @hidden */
  67603. uvPattern: RegExp;
  67604. /** @hidden */
  67605. facePattern1: RegExp;
  67606. /** @hidden */
  67607. facePattern2: RegExp;
  67608. /** @hidden */
  67609. facePattern3: RegExp;
  67610. /** @hidden */
  67611. facePattern4: RegExp;
  67612. /** @hidden */
  67613. facePattern5: RegExp;
  67614. private _meshLoadOptions;
  67615. /**
  67616. * Creates loader for .OBJ files
  67617. *
  67618. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  67619. */
  67620. constructor(meshLoadOptions?: MeshLoadOptions);
  67621. private static readonly currentMeshLoadOptions;
  67622. /**
  67623. * Calls synchronously the MTL file attached to this obj.
  67624. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  67625. * Without this function materials are not displayed in the first frame (but displayed after).
  67626. * In consequence it is impossible to get material information in your HTML file
  67627. *
  67628. * @param url The URL of the MTL file
  67629. * @param rootUrl
  67630. * @param onSuccess Callback function to be called when the MTL file is loaded
  67631. * @private
  67632. */
  67633. private _loadMTL;
  67634. /**
  67635. * Instantiates a OBJ file loader plugin.
  67636. * @returns the created plugin
  67637. */
  67638. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  67639. /**
  67640. * If the data string can be loaded directly.
  67641. *
  67642. * @param data string containing the file data
  67643. * @returns if the data can be loaded directly
  67644. */
  67645. canDirectLoad(data: string): boolean;
  67646. /**
  67647. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  67648. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67649. * @param scene the scene the meshes should be added to
  67650. * @param data the OBJ data to load
  67651. * @param rootUrl root url to load from
  67652. * @param onProgress event that fires when loading progress has occured
  67653. * @param fileName Defines the name of the file to load
  67654. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67655. */
  67656. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67657. meshes: AbstractMesh[];
  67658. particleSystems: IParticleSystem[];
  67659. skeletons: Skeleton[];
  67660. animationGroups: AnimationGroup[];
  67661. }>;
  67662. /**
  67663. * Imports all objects from the loaded OBJ data and adds them to the scene
  67664. * @param scene the scene the objects should be added to
  67665. * @param data the OBJ data to load
  67666. * @param rootUrl root url to load from
  67667. * @param onProgress event that fires when loading progress has occured
  67668. * @param fileName Defines the name of the file to load
  67669. * @returns a promise which completes when objects have been loaded to the scene
  67670. */
  67671. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67672. /**
  67673. * Load into an asset container.
  67674. * @param scene The scene to load into
  67675. * @param data The data to import
  67676. * @param rootUrl The root url for scene and resources
  67677. * @param onProgress The callback when the load progresses
  67678. * @param fileName Defines the name of the file to load
  67679. * @returns The loaded asset container
  67680. */
  67681. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67682. /**
  67683. * Read the OBJ file and create an Array of meshes.
  67684. * Each mesh contains all information given by the OBJ and the MTL file.
  67685. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  67686. *
  67687. * @param meshesNames
  67688. * @param scene Scene The scene where are displayed the data
  67689. * @param data String The content of the obj file
  67690. * @param rootUrl String The path to the folder
  67691. * @returns Array<AbstractMesh>
  67692. * @private
  67693. */
  67694. private _parseSolid;
  67695. }
  67696. }
  67697. declare module BABYLON {
  67698. /**
  67699. * STL file type loader.
  67700. * This is a babylon scene loader plugin.
  67701. */
  67702. export class STLFileLoader implements ISceneLoaderPlugin {
  67703. /** @hidden */
  67704. solidPattern: RegExp;
  67705. /** @hidden */
  67706. facetsPattern: RegExp;
  67707. /** @hidden */
  67708. normalPattern: RegExp;
  67709. /** @hidden */
  67710. vertexPattern: RegExp;
  67711. /**
  67712. * Defines the name of the plugin.
  67713. */
  67714. name: string;
  67715. /**
  67716. * Defines the extensions the stl loader is able to load.
  67717. * force data to come in as an ArrayBuffer
  67718. * we'll convert to string if it looks like it's an ASCII .stl
  67719. */
  67720. extensions: ISceneLoaderPluginExtensions;
  67721. /**
  67722. * Import meshes into a scene.
  67723. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  67724. * @param scene The scene to import into
  67725. * @param data The data to import
  67726. * @param rootUrl The root url for scene and resources
  67727. * @param meshes The meshes array to import into
  67728. * @param particleSystems The particle systems array to import into
  67729. * @param skeletons The skeletons array to import into
  67730. * @param onError The callback when import fails
  67731. * @returns True if successful or false otherwise
  67732. */
  67733. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  67734. /**
  67735. * Load into a scene.
  67736. * @param scene The scene to load into
  67737. * @param data The data to import
  67738. * @param rootUrl The root url for scene and resources
  67739. * @param onError The callback when import fails
  67740. * @returns true if successful or false otherwise
  67741. */
  67742. load(scene: Scene, data: any, rootUrl: string): boolean;
  67743. /**
  67744. * Load into an asset container.
  67745. * @param scene The scene to load into
  67746. * @param data The data to import
  67747. * @param rootUrl The root url for scene and resources
  67748. * @param onError The callback when import fails
  67749. * @returns The loaded asset container
  67750. */
  67751. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  67752. private _isBinary;
  67753. private _parseBinary;
  67754. private _parseASCII;
  67755. }
  67756. }
  67757. declare module BABYLON {
  67758. /**
  67759. * Class for generating OBJ data from a Babylon scene.
  67760. */
  67761. export class OBJExport {
  67762. /**
  67763. * Exports the geometry of a Mesh array in .OBJ file format (text)
  67764. * @param mesh defines the list of meshes to serialize
  67765. * @param materials defines if materials should be exported
  67766. * @param matlibname defines the name of the associated mtl file
  67767. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  67768. * @returns the OBJ content
  67769. */
  67770. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  67771. /**
  67772. * Exports the material(s) of a mesh in .MTL file format (text)
  67773. * @param mesh defines the mesh to extract the material from
  67774. * @returns the mtl content
  67775. */
  67776. static MTL(mesh: Mesh): string;
  67777. }
  67778. }
  67779. declare module BABYLON {
  67780. /** @hidden */
  67781. export var __IGLTFExporterExtension: number;
  67782. /**
  67783. * Interface for extending the exporter
  67784. * @hidden
  67785. */
  67786. export interface IGLTFExporterExtension {
  67787. /**
  67788. * The name of this extension
  67789. */
  67790. readonly name: string;
  67791. /**
  67792. * Defines whether this extension is enabled
  67793. */
  67794. enabled: boolean;
  67795. /**
  67796. * Defines whether this extension is required
  67797. */
  67798. required: boolean;
  67799. }
  67800. }
  67801. declare module BABYLON.GLTF2.Exporter {
  67802. /** @hidden */
  67803. export var __IGLTFExporterExtensionV2: number;
  67804. /**
  67805. * Interface for a glTF exporter extension
  67806. * @hidden
  67807. */
  67808. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67809. /**
  67810. * Define this method to modify the default behavior before exporting a texture
  67811. * @param context The context when loading the asset
  67812. * @param babylonTexture The glTF texture info property
  67813. * @param mimeType The mime-type of the generated image
  67814. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  67815. */
  67816. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67817. /**
  67818. * Define this method to modify the default behavior when exporting texture info
  67819. * @param context The context when loading the asset
  67820. * @param meshPrimitive glTF mesh primitive
  67821. * @param babylonSubMesh Babylon submesh
  67822. * @param binaryWriter glTF serializer binary writer instance
  67823. * @returns nullable IMeshPrimitive promise
  67824. */
  67825. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  67826. /**
  67827. * Define this method to modify the default behavior when exporting a node
  67828. * @param context The context when exporting the node
  67829. * @param node glTF node
  67830. * @param babylonNode BabylonJS node
  67831. * @returns nullable INode promise
  67832. */
  67833. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67834. /**
  67835. * Called after the exporter state changes to EXPORTING
  67836. */
  67837. onExporting?(): void;
  67838. }
  67839. }
  67840. declare module BABYLON.GLTF2.Exporter {
  67841. /**
  67842. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  67843. * @hidden
  67844. */
  67845. export class _GLTFMaterialExporter {
  67846. /**
  67847. * Represents the dielectric specular values for R, G and B
  67848. */
  67849. private static readonly _DielectricSpecular;
  67850. /**
  67851. * Allows the maximum specular power to be defined for material calculations
  67852. */
  67853. private static readonly _MaxSpecularPower;
  67854. /**
  67855. * Mapping to store textures
  67856. */
  67857. private _textureMap;
  67858. /**
  67859. * Numeric tolerance value
  67860. */
  67861. private static readonly _Epsilon;
  67862. /**
  67863. * Reference to the glTF Exporter
  67864. */
  67865. private _exporter;
  67866. constructor(exporter: _Exporter);
  67867. /**
  67868. * Specifies if two colors are approximately equal in value
  67869. * @param color1 first color to compare to
  67870. * @param color2 second color to compare to
  67871. * @param epsilon threshold value
  67872. */
  67873. private static FuzzyEquals;
  67874. /**
  67875. * Gets the materials from a Babylon scene and converts them to glTF materials
  67876. * @param scene babylonjs scene
  67877. * @param mimeType texture mime type
  67878. * @param images array of images
  67879. * @param textures array of textures
  67880. * @param materials array of materials
  67881. * @param imageData mapping of texture names to base64 textures
  67882. * @param hasTextureCoords specifies if texture coordinates are present on the material
  67883. */
  67884. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67885. /**
  67886. * Makes a copy of the glTF material without the texture parameters
  67887. * @param originalMaterial original glTF material
  67888. * @returns glTF material without texture parameters
  67889. */
  67890. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  67891. /**
  67892. * Specifies if the material has any texture parameters present
  67893. * @param material glTF Material
  67894. * @returns boolean specifying if texture parameters are present
  67895. */
  67896. _hasTexturesPresent(material: IMaterial): boolean;
  67897. /**
  67898. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  67899. * @param babylonStandardMaterial
  67900. * @returns glTF Metallic Roughness Material representation
  67901. */
  67902. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  67903. /**
  67904. * Computes the metallic factor
  67905. * @param diffuse diffused value
  67906. * @param specular specular value
  67907. * @param oneMinusSpecularStrength one minus the specular strength
  67908. * @returns metallic value
  67909. */
  67910. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  67911. /**
  67912. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  67913. * @param glTFMaterial glTF material
  67914. * @param babylonMaterial Babylon material
  67915. */
  67916. private static _SetAlphaMode;
  67917. /**
  67918. * Converts a Babylon Standard Material to a glTF Material
  67919. * @param babylonStandardMaterial BJS Standard Material
  67920. * @param mimeType mime type to use for the textures
  67921. * @param images array of glTF image interfaces
  67922. * @param textures array of glTF texture interfaces
  67923. * @param materials array of glTF material interfaces
  67924. * @param imageData map of image file name to data
  67925. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67926. */
  67927. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67928. /**
  67929. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  67930. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  67931. * @param mimeType mime type to use for the textures
  67932. * @param images array of glTF image interfaces
  67933. * @param textures array of glTF texture interfaces
  67934. * @param materials array of glTF material interfaces
  67935. * @param imageData map of image file name to data
  67936. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  67937. */
  67938. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  67939. /**
  67940. * Converts an image typed array buffer to a base64 image
  67941. * @param buffer typed array buffer
  67942. * @param width width of the image
  67943. * @param height height of the image
  67944. * @param mimeType mimetype of the image
  67945. * @returns base64 image string
  67946. */
  67947. private _createBase64FromCanvasAsync;
  67948. /**
  67949. * Generates a white texture based on the specified width and height
  67950. * @param width width of the texture in pixels
  67951. * @param height height of the texture in pixels
  67952. * @param scene babylonjs scene
  67953. * @returns white texture
  67954. */
  67955. private _createWhiteTexture;
  67956. /**
  67957. * 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
  67958. * @param texture1 first texture to resize
  67959. * @param texture2 second texture to resize
  67960. * @param scene babylonjs scene
  67961. * @returns resized textures or null
  67962. */
  67963. private _resizeTexturesToSameDimensions;
  67964. /**
  67965. * Converts an array of pixels to a Float32Array
  67966. * Throws an error if the pixel format is not supported
  67967. * @param pixels - array buffer containing pixel values
  67968. * @returns Float32 of pixels
  67969. */
  67970. private _convertPixelArrayToFloat32;
  67971. /**
  67972. * Convert Specular Glossiness Textures to Metallic Roughness
  67973. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  67974. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  67975. * @param diffuseTexture texture used to store diffuse information
  67976. * @param specularGlossinessTexture texture used to store specular and glossiness information
  67977. * @param factors specular glossiness material factors
  67978. * @param mimeType the mime type to use for the texture
  67979. * @returns pbr metallic roughness interface or null
  67980. */
  67981. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  67982. /**
  67983. * Converts specular glossiness material properties to metallic roughness
  67984. * @param specularGlossiness interface with specular glossiness material properties
  67985. * @returns interface with metallic roughness material properties
  67986. */
  67987. private _convertSpecularGlossinessToMetallicRoughness;
  67988. /**
  67989. * Calculates the surface reflectance, independent of lighting conditions
  67990. * @param color Color source to calculate brightness from
  67991. * @returns number representing the perceived brightness, or zero if color is undefined
  67992. */
  67993. private _getPerceivedBrightness;
  67994. /**
  67995. * Returns the maximum color component value
  67996. * @param color
  67997. * @returns maximum color component value, or zero if color is null or undefined
  67998. */
  67999. private _getMaxComponent;
  68000. /**
  68001. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68002. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68003. * @param mimeType mime type to use for the textures
  68004. * @param images array of glTF image interfaces
  68005. * @param textures array of glTF texture interfaces
  68006. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68007. * @param imageData map of image file name to data
  68008. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68009. * @returns glTF PBR Metallic Roughness factors
  68010. */
  68011. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68012. private _getGLTFTextureSampler;
  68013. private _getGLTFTextureWrapMode;
  68014. private _getGLTFTextureWrapModesSampler;
  68015. /**
  68016. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68017. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68018. * @param mimeType mime type to use for the textures
  68019. * @param images array of glTF image interfaces
  68020. * @param textures array of glTF texture interfaces
  68021. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68022. * @param imageData map of image file name to data
  68023. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68024. * @returns glTF PBR Metallic Roughness factors
  68025. */
  68026. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68027. /**
  68028. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68029. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68030. * @param mimeType mime type to use for the textures
  68031. * @param images array of glTF image interfaces
  68032. * @param textures array of glTF texture interfaces
  68033. * @param materials array of glTF material interfaces
  68034. * @param imageData map of image file name to data
  68035. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68036. */
  68037. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68038. private setMetallicRoughnessPbrMaterial;
  68039. private getPixelsFromTexture;
  68040. /**
  68041. * Extracts a texture from a Babylon texture into file data and glTF data
  68042. * @param babylonTexture Babylon texture to extract
  68043. * @param mimeType Mime Type of the babylonTexture
  68044. * @return glTF texture info, or null if the texture format is not supported
  68045. */
  68046. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68047. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68048. /**
  68049. * Builds a texture from base64 string
  68050. * @param base64Texture base64 texture string
  68051. * @param baseTextureName Name to use for the texture
  68052. * @param mimeType image mime type for the texture
  68053. * @param images array of images
  68054. * @param textures array of textures
  68055. * @param imageData map of image data
  68056. * @returns glTF texture info, or null if the texture format is not supported
  68057. */
  68058. private _getTextureInfoFromBase64;
  68059. }
  68060. }
  68061. declare module BABYLON {
  68062. /**
  68063. * Class for holding and downloading glTF file data
  68064. */
  68065. export class GLTFData {
  68066. /**
  68067. * Object which contains the file name as the key and its data as the value
  68068. */
  68069. glTFFiles: {
  68070. [fileName: string]: string | Blob;
  68071. };
  68072. /**
  68073. * Initializes the glTF file object
  68074. */
  68075. constructor();
  68076. /**
  68077. * Downloads the glTF data as files based on their names and data
  68078. */
  68079. downloadFiles(): void;
  68080. }
  68081. }
  68082. declare module BABYLON {
  68083. /**
  68084. * Holds a collection of exporter options and parameters
  68085. */
  68086. export interface IExportOptions {
  68087. /**
  68088. * Function which indicates whether a babylon node should be exported or not
  68089. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68090. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68091. */
  68092. shouldExportNode?(node: Node): boolean;
  68093. /**
  68094. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68095. * @param metadata source metadata to read from
  68096. * @returns the data to store to glTF node extras
  68097. */
  68098. metadataSelector?(metadata: any): any;
  68099. /**
  68100. * The sample rate to bake animation curves
  68101. */
  68102. animationSampleRate?: number;
  68103. /**
  68104. * Begin serialization without waiting for the scene to be ready
  68105. */
  68106. exportWithoutWaitingForScene?: boolean;
  68107. }
  68108. /**
  68109. * Class for generating glTF data from a Babylon scene.
  68110. */
  68111. export class GLTF2Export {
  68112. /**
  68113. * Exports the geometry of the scene to .gltf file format asynchronously
  68114. * @param scene Babylon scene with scene hierarchy information
  68115. * @param filePrefix File prefix to use when generating the glTF file
  68116. * @param options Exporter options
  68117. * @returns Returns an object with a .gltf file and associates texture names
  68118. * as keys and their data and paths as values
  68119. */
  68120. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68121. private static _PreExportAsync;
  68122. private static _PostExportAsync;
  68123. /**
  68124. * Exports the geometry of the scene to .glb file format asychronously
  68125. * @param scene Babylon scene with scene hierarchy information
  68126. * @param filePrefix File prefix to use when generating glb file
  68127. * @param options Exporter options
  68128. * @returns Returns an object with a .glb filename as key and data as value
  68129. */
  68130. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68131. }
  68132. }
  68133. declare module BABYLON.GLTF2.Exporter {
  68134. /**
  68135. * @hidden
  68136. */
  68137. export class _GLTFUtilities {
  68138. /**
  68139. * Creates a buffer view based on the supplied arguments
  68140. * @param bufferIndex index value of the specified buffer
  68141. * @param byteOffset byte offset value
  68142. * @param byteLength byte length of the bufferView
  68143. * @param byteStride byte distance between conequential elements
  68144. * @param name name of the buffer view
  68145. * @returns bufferView for glTF
  68146. */
  68147. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68148. /**
  68149. * Creates an accessor based on the supplied arguments
  68150. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68151. * @param name The name of the accessor
  68152. * @param type The type of the accessor
  68153. * @param componentType The datatype of components in the attribute
  68154. * @param count The number of attributes referenced by this accessor
  68155. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68156. * @param min Minimum value of each component in this attribute
  68157. * @param max Maximum value of each component in this attribute
  68158. * @returns accessor for glTF
  68159. */
  68160. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68161. /**
  68162. * Calculates the minimum and maximum values of an array of position floats
  68163. * @param positions Positions array of a mesh
  68164. * @param vertexStart Starting vertex offset to calculate min and max values
  68165. * @param vertexCount Number of vertices to check for min and max values
  68166. * @returns min number array and max number array
  68167. */
  68168. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68169. min: number[];
  68170. max: number[];
  68171. };
  68172. /**
  68173. * Converts a new right-handed Vector3
  68174. * @param vector vector3 array
  68175. * @returns right-handed Vector3
  68176. */
  68177. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68178. /**
  68179. * Converts a Vector3 to right-handed
  68180. * @param vector Vector3 to convert to right-handed
  68181. */
  68182. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68183. /**
  68184. * Converts a three element number array to right-handed
  68185. * @param vector number array to convert to right-handed
  68186. */
  68187. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68188. /**
  68189. * Converts a new right-handed Vector3
  68190. * @param vector vector3 array
  68191. * @returns right-handed Vector3
  68192. */
  68193. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68194. /**
  68195. * Converts a Vector3 to right-handed
  68196. * @param vector Vector3 to convert to right-handed
  68197. */
  68198. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68199. /**
  68200. * Converts a three element number array to right-handed
  68201. * @param vector number array to convert to right-handed
  68202. */
  68203. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68204. /**
  68205. * Converts a Vector4 to right-handed
  68206. * @param vector Vector4 to convert to right-handed
  68207. */
  68208. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68209. /**
  68210. * Converts a Vector4 to right-handed
  68211. * @param vector Vector4 to convert to right-handed
  68212. */
  68213. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68214. /**
  68215. * Converts a Quaternion to right-handed
  68216. * @param quaternion Source quaternion to convert to right-handed
  68217. */
  68218. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68219. /**
  68220. * Converts a Quaternion to right-handed
  68221. * @param quaternion Source quaternion to convert to right-handed
  68222. */
  68223. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68224. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68225. }
  68226. }
  68227. declare module BABYLON.GLTF2.Exporter {
  68228. /**
  68229. * Converts Babylon Scene into glTF 2.0.
  68230. * @hidden
  68231. */
  68232. export class _Exporter {
  68233. /**
  68234. * Stores the glTF to export
  68235. */
  68236. _glTF: IGLTF;
  68237. /**
  68238. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68239. */
  68240. _bufferViews: IBufferView[];
  68241. /**
  68242. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68243. */
  68244. _accessors: IAccessor[];
  68245. /**
  68246. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68247. */
  68248. private _nodes;
  68249. /**
  68250. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68251. */
  68252. private _scenes;
  68253. /**
  68254. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68255. */
  68256. private _meshes;
  68257. /**
  68258. * Stores all the generated material information, which represents the appearance of each primitive
  68259. */
  68260. _materials: IMaterial[];
  68261. _materialMap: {
  68262. [materialID: number]: number;
  68263. };
  68264. /**
  68265. * Stores all the generated texture information, which is referenced by glTF materials
  68266. */
  68267. _textures: ITexture[];
  68268. /**
  68269. * Stores all the generated image information, which is referenced by glTF textures
  68270. */
  68271. _images: IImage[];
  68272. /**
  68273. * Stores all the texture samplers
  68274. */
  68275. _samplers: ISampler[];
  68276. /**
  68277. * Stores all the generated animation samplers, which is referenced by glTF animations
  68278. */
  68279. /**
  68280. * Stores the animations for glTF models
  68281. */
  68282. private _animations;
  68283. /**
  68284. * Stores the total amount of bytes stored in the glTF buffer
  68285. */
  68286. private _totalByteLength;
  68287. /**
  68288. * Stores a reference to the Babylon scene containing the source geometry and material information
  68289. */
  68290. _babylonScene: Scene;
  68291. /**
  68292. * Stores a map of the image data, where the key is the file name and the value
  68293. * is the image data
  68294. */
  68295. _imageData: {
  68296. [fileName: string]: {
  68297. data: Uint8Array;
  68298. mimeType: ImageMimeType;
  68299. };
  68300. };
  68301. /**
  68302. * Stores a map of the unique id of a node to its index in the node array
  68303. */
  68304. private _nodeMap;
  68305. /**
  68306. * Specifies if the Babylon scene should be converted to right-handed on export
  68307. */
  68308. _convertToRightHandedSystem: boolean;
  68309. /**
  68310. * Baked animation sample rate
  68311. */
  68312. private _animationSampleRate;
  68313. private _options;
  68314. private _localEngine;
  68315. _glTFMaterialExporter: _GLTFMaterialExporter;
  68316. private _extensions;
  68317. private static _ExtensionNames;
  68318. private static _ExtensionFactories;
  68319. private _applyExtensions;
  68320. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  68321. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68322. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68323. private _forEachExtensions;
  68324. private _extensionsOnExporting;
  68325. /**
  68326. * Load glTF serializer extensions
  68327. */
  68328. private _loadExtensions;
  68329. /**
  68330. * Creates a glTF Exporter instance, which can accept optional exporter options
  68331. * @param babylonScene Babylon scene object
  68332. * @param options Options to modify the behavior of the exporter
  68333. */
  68334. constructor(babylonScene: Scene, options?: IExportOptions);
  68335. /**
  68336. * Registers a glTF exporter extension
  68337. * @param name Name of the extension to export
  68338. * @param factory The factory function that creates the exporter extension
  68339. */
  68340. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68341. /**
  68342. * Un-registers an exporter extension
  68343. * @param name The name fo the exporter extension
  68344. * @returns A boolean indicating whether the extension has been un-registered
  68345. */
  68346. static UnregisterExtension(name: string): boolean;
  68347. /**
  68348. * Lazy load a local engine with premultiplied alpha set to false
  68349. */
  68350. _getLocalEngine(): Engine;
  68351. private reorderIndicesBasedOnPrimitiveMode;
  68352. /**
  68353. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  68354. * clock-wise during export to glTF
  68355. * @param submesh BabylonJS submesh
  68356. * @param primitiveMode Primitive mode of the mesh
  68357. * @param sideOrientation the winding order of the submesh
  68358. * @param vertexBufferKind The type of vertex attribute
  68359. * @param meshAttributeArray The vertex attribute data
  68360. * @param byteOffset The offset to the binary data
  68361. * @param binaryWriter The binary data for the glTF file
  68362. */
  68363. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  68364. /**
  68365. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  68366. * clock-wise during export to glTF
  68367. * @param submesh BabylonJS submesh
  68368. * @param primitiveMode Primitive mode of the mesh
  68369. * @param sideOrientation the winding order of the submesh
  68370. * @param vertexBufferKind The type of vertex attribute
  68371. * @param meshAttributeArray The vertex attribute data
  68372. * @param byteOffset The offset to the binary data
  68373. * @param binaryWriter The binary data for the glTF file
  68374. */
  68375. private reorderTriangleFillMode;
  68376. /**
  68377. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  68378. * clock-wise during export to glTF
  68379. * @param submesh BabylonJS submesh
  68380. * @param primitiveMode Primitive mode of the mesh
  68381. * @param sideOrientation the winding order of the submesh
  68382. * @param vertexBufferKind The type of vertex attribute
  68383. * @param meshAttributeArray The vertex attribute data
  68384. * @param byteOffset The offset to the binary data
  68385. * @param binaryWriter The binary data for the glTF file
  68386. */
  68387. private reorderTriangleStripDrawMode;
  68388. /**
  68389. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  68390. * clock-wise during export to glTF
  68391. * @param submesh BabylonJS submesh
  68392. * @param primitiveMode Primitive mode of the mesh
  68393. * @param sideOrientation the winding order of the submesh
  68394. * @param vertexBufferKind The type of vertex attribute
  68395. * @param meshAttributeArray The vertex attribute data
  68396. * @param byteOffset The offset to the binary data
  68397. * @param binaryWriter The binary data for the glTF file
  68398. */
  68399. private reorderTriangleFanMode;
  68400. /**
  68401. * Writes the vertex attribute data to binary
  68402. * @param vertices The vertices to write to the binary writer
  68403. * @param byteOffset The offset into the binary writer to overwrite binary data
  68404. * @param vertexAttributeKind The vertex attribute type
  68405. * @param meshAttributeArray The vertex attribute data
  68406. * @param binaryWriter The writer containing the binary data
  68407. */
  68408. private writeVertexAttributeData;
  68409. /**
  68410. * Writes mesh attribute data to a data buffer
  68411. * Returns the bytelength of the data
  68412. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  68413. * @param meshAttributeArray Array containing the attribute data
  68414. * @param binaryWriter The buffer to write the binary data to
  68415. * @param indices Used to specify the order of the vertex data
  68416. */
  68417. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  68418. /**
  68419. * Generates glTF json data
  68420. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  68421. * @param glTFPrefix Text to use when prefixing a glTF file
  68422. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  68423. * @returns json data as string
  68424. */
  68425. private generateJSON;
  68426. /**
  68427. * Generates data for .gltf and .bin files based on the glTF prefix string
  68428. * @param glTFPrefix Text to use when prefixing a glTF file
  68429. * @returns GLTFData with glTF file data
  68430. */
  68431. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  68432. /**
  68433. * Creates a binary buffer for glTF
  68434. * @returns array buffer for binary data
  68435. */
  68436. private _generateBinaryAsync;
  68437. /**
  68438. * Pads the number to a multiple of 4
  68439. * @param num number to pad
  68440. * @returns padded number
  68441. */
  68442. private _getPadding;
  68443. /**
  68444. * Generates a glb file from the json and binary data
  68445. * Returns an object with the glb file name as the key and data as the value
  68446. * @param glTFPrefix
  68447. * @returns object with glb filename as key and data as value
  68448. */
  68449. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  68450. /**
  68451. * Sets the TRS for each node
  68452. * @param node glTF Node for storing the transformation data
  68453. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  68454. */
  68455. private setNodeTransformation;
  68456. private getVertexBufferFromMesh;
  68457. /**
  68458. * Creates a bufferview based on the vertices type for the Babylon mesh
  68459. * @param kind Indicates the type of vertices data
  68460. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  68461. * @param binaryWriter The buffer to write the bufferview data to
  68462. */
  68463. private createBufferViewKind;
  68464. /**
  68465. * The primitive mode of the Babylon mesh
  68466. * @param babylonMesh The BabylonJS mesh
  68467. */
  68468. private getMeshPrimitiveMode;
  68469. /**
  68470. * Sets the primitive mode of the glTF mesh primitive
  68471. * @param meshPrimitive glTF mesh primitive
  68472. * @param primitiveMode The primitive mode
  68473. */
  68474. private setPrimitiveMode;
  68475. /**
  68476. * Sets the vertex attribute accessor based of the glTF mesh primitive
  68477. * @param meshPrimitive glTF mesh primitive
  68478. * @param attributeKind vertex attribute
  68479. * @returns boolean specifying if uv coordinates are present
  68480. */
  68481. private setAttributeKind;
  68482. /**
  68483. * Sets data for the primitive attributes of each submesh
  68484. * @param mesh glTF Mesh object to store the primitive attribute information
  68485. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  68486. * @param binaryWriter Buffer to write the attribute data to
  68487. */
  68488. private setPrimitiveAttributesAsync;
  68489. /**
  68490. * Creates a glTF scene based on the array of meshes
  68491. * Returns the the total byte offset
  68492. * @param babylonScene Babylon scene to get the mesh data from
  68493. * @param binaryWriter Buffer to write binary data to
  68494. */
  68495. private createSceneAsync;
  68496. /**
  68497. * Creates a mapping of Node unique id to node index and handles animations
  68498. * @param babylonScene Babylon Scene
  68499. * @param nodes Babylon transform nodes
  68500. * @param binaryWriter Buffer to write binary data to
  68501. * @returns Node mapping of unique id to index
  68502. */
  68503. private createNodeMapAndAnimationsAsync;
  68504. /**
  68505. * Creates a glTF node from a Babylon mesh
  68506. * @param babylonMesh Source Babylon mesh
  68507. * @param binaryWriter Buffer for storing geometry data
  68508. * @returns glTF node
  68509. */
  68510. private createNodeAsync;
  68511. }
  68512. /**
  68513. * @hidden
  68514. *
  68515. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  68516. */
  68517. export class _BinaryWriter {
  68518. /**
  68519. * Array buffer which stores all binary data
  68520. */
  68521. private _arrayBuffer;
  68522. /**
  68523. * View of the array buffer
  68524. */
  68525. private _dataView;
  68526. /**
  68527. * byte offset of data in array buffer
  68528. */
  68529. private _byteOffset;
  68530. /**
  68531. * Initialize binary writer with an initial byte length
  68532. * @param byteLength Initial byte length of the array buffer
  68533. */
  68534. constructor(byteLength: number);
  68535. /**
  68536. * Resize the array buffer to the specified byte length
  68537. * @param byteLength
  68538. */
  68539. private resizeBuffer;
  68540. /**
  68541. * Get an array buffer with the length of the byte offset
  68542. * @returns ArrayBuffer resized to the byte offset
  68543. */
  68544. getArrayBuffer(): ArrayBuffer;
  68545. /**
  68546. * Get the byte offset of the array buffer
  68547. * @returns byte offset
  68548. */
  68549. getByteOffset(): number;
  68550. /**
  68551. * Stores an UInt8 in the array buffer
  68552. * @param entry
  68553. * @param byteOffset If defined, specifies where to set the value as an offset.
  68554. */
  68555. setUInt8(entry: number, byteOffset?: number): void;
  68556. /**
  68557. * Gets an UInt32 in the array buffer
  68558. * @param entry
  68559. * @param byteOffset If defined, specifies where to set the value as an offset.
  68560. */
  68561. getUInt32(byteOffset: number): number;
  68562. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68563. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  68564. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68565. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  68566. /**
  68567. * Stores a Float32 in the array buffer
  68568. * @param entry
  68569. */
  68570. setFloat32(entry: number, byteOffset?: number): void;
  68571. /**
  68572. * Stores an UInt32 in the array buffer
  68573. * @param entry
  68574. * @param byteOffset If defined, specifies where to set the value as an offset.
  68575. */
  68576. setUInt32(entry: number, byteOffset?: number): void;
  68577. }
  68578. }
  68579. declare module BABYLON.GLTF2.Exporter {
  68580. /**
  68581. * @hidden
  68582. * Interface to store animation data.
  68583. */
  68584. export interface _IAnimationData {
  68585. /**
  68586. * Keyframe data.
  68587. */
  68588. inputs: number[];
  68589. /**
  68590. * Value data.
  68591. */
  68592. outputs: number[][];
  68593. /**
  68594. * Animation interpolation data.
  68595. */
  68596. samplerInterpolation: AnimationSamplerInterpolation;
  68597. /**
  68598. * Minimum keyframe value.
  68599. */
  68600. inputsMin: number;
  68601. /**
  68602. * Maximum keyframe value.
  68603. */
  68604. inputsMax: number;
  68605. }
  68606. /**
  68607. * @hidden
  68608. */
  68609. export interface _IAnimationInfo {
  68610. /**
  68611. * The target channel for the animation
  68612. */
  68613. animationChannelTargetPath: AnimationChannelTargetPath;
  68614. /**
  68615. * The glTF accessor type for the data.
  68616. */
  68617. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  68618. /**
  68619. * Specifies if quaternions should be used.
  68620. */
  68621. useQuaternion: boolean;
  68622. }
  68623. /**
  68624. * @hidden
  68625. * Utility class for generating glTF animation data from BabylonJS.
  68626. */
  68627. export class _GLTFAnimation {
  68628. /**
  68629. * @ignore
  68630. *
  68631. * Creates glTF channel animation from BabylonJS animation.
  68632. * @param babylonTransformNode - BabylonJS mesh.
  68633. * @param animation - animation.
  68634. * @param animationChannelTargetPath - The target animation channel.
  68635. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  68636. * @param useQuaternion - Specifies if quaternions are used.
  68637. * @returns nullable IAnimationData
  68638. */
  68639. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  68640. private static _DeduceAnimationInfo;
  68641. /**
  68642. * @ignore
  68643. * Create node animations from the transform node animations
  68644. * @param babylonNode
  68645. * @param runtimeGLTFAnimation
  68646. * @param idleGLTFAnimations
  68647. * @param nodeMap
  68648. * @param nodes
  68649. * @param binaryWriter
  68650. * @param bufferViews
  68651. * @param accessors
  68652. * @param convertToRightHandedSystem
  68653. */
  68654. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  68655. [key: number]: number;
  68656. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68657. /**
  68658. * @ignore
  68659. * Create node animations from the animation groups
  68660. * @param babylonScene
  68661. * @param glTFAnimations
  68662. * @param nodeMap
  68663. * @param nodes
  68664. * @param binaryWriter
  68665. * @param bufferViews
  68666. * @param accessors
  68667. * @param convertToRightHandedSystem
  68668. */
  68669. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  68670. [key: number]: number;
  68671. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  68672. private static AddAnimation;
  68673. /**
  68674. * Create a baked animation
  68675. * @param babylonTransformNode BabylonJS mesh
  68676. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  68677. * @param animationChannelTargetPath animation target channel
  68678. * @param minFrame minimum animation frame
  68679. * @param maxFrame maximum animation frame
  68680. * @param fps frames per second of the animation
  68681. * @param inputs input key frames of the animation
  68682. * @param outputs output key frame data of the animation
  68683. * @param convertToRightHandedSystem converts the values to right-handed
  68684. * @param useQuaternion specifies if quaternions should be used
  68685. */
  68686. private static _CreateBakedAnimation;
  68687. private static _ConvertFactorToVector3OrQuaternion;
  68688. private static _SetInterpolatedValue;
  68689. /**
  68690. * Creates linear animation from the animation key frames
  68691. * @param babylonTransformNode BabylonJS mesh
  68692. * @param animation BabylonJS animation
  68693. * @param animationChannelTargetPath The target animation channel
  68694. * @param frameDelta The difference between the last and first frame of the animation
  68695. * @param inputs Array to store the key frame times
  68696. * @param outputs Array to store the key frame data
  68697. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68698. * @param useQuaternion Specifies if quaternions are used in the animation
  68699. */
  68700. private static _CreateLinearOrStepAnimation;
  68701. /**
  68702. * Creates cubic spline animation from the animation key frames
  68703. * @param babylonTransformNode BabylonJS mesh
  68704. * @param animation BabylonJS animation
  68705. * @param animationChannelTargetPath The target animation channel
  68706. * @param frameDelta The difference between the last and first frame of the animation
  68707. * @param inputs Array to store the key frame times
  68708. * @param outputs Array to store the key frame data
  68709. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  68710. * @param useQuaternion Specifies if quaternions are used in the animation
  68711. */
  68712. private static _CreateCubicSplineAnimation;
  68713. private static _GetBasePositionRotationOrScale;
  68714. /**
  68715. * Adds a key frame value
  68716. * @param keyFrame
  68717. * @param animation
  68718. * @param outputs
  68719. * @param animationChannelTargetPath
  68720. * @param basePositionRotationOrScale
  68721. * @param convertToRightHandedSystem
  68722. * @param useQuaternion
  68723. */
  68724. private static _AddKeyframeValue;
  68725. /**
  68726. * Determine the interpolation based on the key frames
  68727. * @param keyFrames
  68728. * @param animationChannelTargetPath
  68729. * @param useQuaternion
  68730. */
  68731. private static _DeduceInterpolation;
  68732. /**
  68733. * Adds an input tangent or output tangent to the output data
  68734. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  68735. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  68736. * @param outputs The animation data by keyframe
  68737. * @param animationChannelTargetPath The target animation channel
  68738. * @param interpolation The interpolation type
  68739. * @param keyFrame The key frame with the animation data
  68740. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  68741. * @param useQuaternion Specifies if quaternions are used
  68742. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  68743. */
  68744. private static AddSplineTangent;
  68745. /**
  68746. * Get the minimum and maximum key frames' frame values
  68747. * @param keyFrames animation key frames
  68748. * @returns the minimum and maximum key frame value
  68749. */
  68750. private static calculateMinMaxKeyFrames;
  68751. }
  68752. }
  68753. declare module BABYLON.GLTF2.Exporter {
  68754. /** @hidden */
  68755. export var textureTransformPixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module BABYLON.GLTF2.Exporter.Extensions {
  68761. /**
  68762. * @hidden
  68763. */
  68764. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  68765. /** Name of this extension */
  68766. readonly name: string;
  68767. /** Defines whether this extension is enabled */
  68768. enabled: boolean;
  68769. /** Defines whether this extension is required */
  68770. required: boolean;
  68771. /** Reference to the glTF exporter */
  68772. private _exporter;
  68773. constructor(exporter: _Exporter);
  68774. dispose(): void;
  68775. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68776. /**
  68777. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  68778. * @param babylonTexture
  68779. * @param offset
  68780. * @param rotation
  68781. * @param scale
  68782. * @param scene
  68783. */
  68784. private _textureTransformTextureAsync;
  68785. }
  68786. }
  68787. declare module BABYLON.GLTF2.Exporter.Extensions {
  68788. /**
  68789. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  68790. */
  68791. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  68792. /** The name of this extension. */
  68793. readonly name: string;
  68794. /** Defines whether this extension is enabled. */
  68795. enabled: boolean;
  68796. /** Defines whether this extension is required */
  68797. required: boolean;
  68798. /** Reference to the glTF exporter */
  68799. private _exporter;
  68800. private _lights;
  68801. /** @hidden */
  68802. constructor(exporter: _Exporter);
  68803. /** @hidden */
  68804. dispose(): void;
  68805. /** @hidden */
  68806. onExporting(): void;
  68807. /**
  68808. * Define this method to modify the default behavior when exporting a node
  68809. * @param context The context when exporting the node
  68810. * @param node glTF node
  68811. * @param babylonNode BabylonJS node
  68812. * @returns nullable INode promise
  68813. */
  68814. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * Class for generating STL data from a Babylon scene.
  68820. */
  68821. export class STLExport {
  68822. /**
  68823. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  68824. * @param meshes list defines the mesh to serialize
  68825. * @param download triggers the automatic download of the file.
  68826. * @param fileName changes the downloads fileName.
  68827. * @param binary changes the STL to a binary type.
  68828. * @param isLittleEndian toggle for binary type exporter.
  68829. * @returns the STL as UTF8 string
  68830. */
  68831. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  68832. }
  68833. }
  68834. /**
  68835. * @ignoreChildren
  68836. * @ignore
  68837. */
  68838. declare module "babylonjs-gltf2interface" {
  68839. export = BABYLON.GLTF2;
  68840. }
  68841. /**
  68842. * Module for glTF 2.0 Interface
  68843. * @ignoreChildren
  68844. * @ignore
  68845. */
  68846. declare module BABYLON.GLTF2 {
  68847. /**
  68848. * The datatype of the components in the attribute
  68849. */
  68850. const enum AccessorComponentType {
  68851. /**
  68852. * Byte
  68853. */
  68854. BYTE = 5120,
  68855. /**
  68856. * Unsigned Byte
  68857. */
  68858. UNSIGNED_BYTE = 5121,
  68859. /**
  68860. * Short
  68861. */
  68862. SHORT = 5122,
  68863. /**
  68864. * Unsigned Short
  68865. */
  68866. UNSIGNED_SHORT = 5123,
  68867. /**
  68868. * Unsigned Int
  68869. */
  68870. UNSIGNED_INT = 5125,
  68871. /**
  68872. * Float
  68873. */
  68874. FLOAT = 5126,
  68875. }
  68876. /**
  68877. * Specifies if the attirbute is a scalar, vector, or matrix
  68878. */
  68879. const enum AccessorType {
  68880. /**
  68881. * Scalar
  68882. */
  68883. SCALAR = "SCALAR",
  68884. /**
  68885. * Vector2
  68886. */
  68887. VEC2 = "VEC2",
  68888. /**
  68889. * Vector3
  68890. */
  68891. VEC3 = "VEC3",
  68892. /**
  68893. * Vector4
  68894. */
  68895. VEC4 = "VEC4",
  68896. /**
  68897. * Matrix2x2
  68898. */
  68899. MAT2 = "MAT2",
  68900. /**
  68901. * Matrix3x3
  68902. */
  68903. MAT3 = "MAT3",
  68904. /**
  68905. * Matrix4x4
  68906. */
  68907. MAT4 = "MAT4",
  68908. }
  68909. /**
  68910. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  68911. */
  68912. const enum AnimationChannelTargetPath {
  68913. /**
  68914. * Translation
  68915. */
  68916. TRANSLATION = "translation",
  68917. /**
  68918. * Rotation
  68919. */
  68920. ROTATION = "rotation",
  68921. /**
  68922. * Scale
  68923. */
  68924. SCALE = "scale",
  68925. /**
  68926. * Weights
  68927. */
  68928. WEIGHTS = "weights",
  68929. }
  68930. /**
  68931. * Interpolation algorithm
  68932. */
  68933. const enum AnimationSamplerInterpolation {
  68934. /**
  68935. * The animated values are linearly interpolated between keyframes
  68936. */
  68937. LINEAR = "LINEAR",
  68938. /**
  68939. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  68940. */
  68941. STEP = "STEP",
  68942. /**
  68943. * The animation's interpolation is computed using a cubic spline with specified tangents
  68944. */
  68945. CUBICSPLINE = "CUBICSPLINE",
  68946. }
  68947. /**
  68948. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  68949. */
  68950. const enum CameraType {
  68951. /**
  68952. * A perspective camera containing properties to create a perspective projection matrix
  68953. */
  68954. PERSPECTIVE = "perspective",
  68955. /**
  68956. * An orthographic camera containing properties to create an orthographic projection matrix
  68957. */
  68958. ORTHOGRAPHIC = "orthographic",
  68959. }
  68960. /**
  68961. * The mime-type of the image
  68962. */
  68963. const enum ImageMimeType {
  68964. /**
  68965. * JPEG Mime-type
  68966. */
  68967. JPEG = "image/jpeg",
  68968. /**
  68969. * PNG Mime-type
  68970. */
  68971. PNG = "image/png",
  68972. }
  68973. /**
  68974. * The alpha rendering mode of the material
  68975. */
  68976. const enum MaterialAlphaMode {
  68977. /**
  68978. * The alpha value is ignored and the rendered output is fully opaque
  68979. */
  68980. OPAQUE = "OPAQUE",
  68981. /**
  68982. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  68983. */
  68984. MASK = "MASK",
  68985. /**
  68986. * 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)
  68987. */
  68988. BLEND = "BLEND",
  68989. }
  68990. /**
  68991. * The type of the primitives to render
  68992. */
  68993. const enum MeshPrimitiveMode {
  68994. /**
  68995. * Points
  68996. */
  68997. POINTS = 0,
  68998. /**
  68999. * Lines
  69000. */
  69001. LINES = 1,
  69002. /**
  69003. * Line Loop
  69004. */
  69005. LINE_LOOP = 2,
  69006. /**
  69007. * Line Strip
  69008. */
  69009. LINE_STRIP = 3,
  69010. /**
  69011. * Triangles
  69012. */
  69013. TRIANGLES = 4,
  69014. /**
  69015. * Triangle Strip
  69016. */
  69017. TRIANGLE_STRIP = 5,
  69018. /**
  69019. * Triangle Fan
  69020. */
  69021. TRIANGLE_FAN = 6,
  69022. }
  69023. /**
  69024. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69025. */
  69026. const enum TextureMagFilter {
  69027. /**
  69028. * Nearest
  69029. */
  69030. NEAREST = 9728,
  69031. /**
  69032. * Linear
  69033. */
  69034. LINEAR = 9729,
  69035. }
  69036. /**
  69037. * Minification filter. All valid values correspond to WebGL enums
  69038. */
  69039. const enum TextureMinFilter {
  69040. /**
  69041. * Nearest
  69042. */
  69043. NEAREST = 9728,
  69044. /**
  69045. * Linear
  69046. */
  69047. LINEAR = 9729,
  69048. /**
  69049. * Nearest Mip-Map Nearest
  69050. */
  69051. NEAREST_MIPMAP_NEAREST = 9984,
  69052. /**
  69053. * Linear Mipmap Nearest
  69054. */
  69055. LINEAR_MIPMAP_NEAREST = 9985,
  69056. /**
  69057. * Nearest Mipmap Linear
  69058. */
  69059. NEAREST_MIPMAP_LINEAR = 9986,
  69060. /**
  69061. * Linear Mipmap Linear
  69062. */
  69063. LINEAR_MIPMAP_LINEAR = 9987,
  69064. }
  69065. /**
  69066. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69067. */
  69068. const enum TextureWrapMode {
  69069. /**
  69070. * Clamp to Edge
  69071. */
  69072. CLAMP_TO_EDGE = 33071,
  69073. /**
  69074. * Mirrored Repeat
  69075. */
  69076. MIRRORED_REPEAT = 33648,
  69077. /**
  69078. * Repeat
  69079. */
  69080. REPEAT = 10497,
  69081. }
  69082. /**
  69083. * glTF Property
  69084. */
  69085. interface IProperty {
  69086. /**
  69087. * Dictionary object with extension-specific objects
  69088. */
  69089. extensions?: {
  69090. [key: string]: any;
  69091. };
  69092. /**
  69093. * Application-Specific data
  69094. */
  69095. extras?: any;
  69096. }
  69097. /**
  69098. * glTF Child of Root Property
  69099. */
  69100. interface IChildRootProperty extends IProperty {
  69101. /**
  69102. * The user-defined name of this object
  69103. */
  69104. name?: string;
  69105. }
  69106. /**
  69107. * Indices of those attributes that deviate from their initialization value
  69108. */
  69109. interface IAccessorSparseIndices extends IProperty {
  69110. /**
  69111. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69112. */
  69113. bufferView: number;
  69114. /**
  69115. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69116. */
  69117. byteOffset?: number;
  69118. /**
  69119. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69120. */
  69121. componentType: AccessorComponentType;
  69122. }
  69123. /**
  69124. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69125. */
  69126. interface IAccessorSparseValues extends IProperty {
  69127. /**
  69128. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69129. */
  69130. bufferView: number;
  69131. /**
  69132. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69133. */
  69134. byteOffset?: number;
  69135. }
  69136. /**
  69137. * Sparse storage of attributes that deviate from their initialization value
  69138. */
  69139. interface IAccessorSparse extends IProperty {
  69140. /**
  69141. * The number of attributes encoded in this sparse accessor
  69142. */
  69143. count: number;
  69144. /**
  69145. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69146. */
  69147. indices: IAccessorSparseIndices;
  69148. /**
  69149. * 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
  69150. */
  69151. values: IAccessorSparseValues;
  69152. }
  69153. /**
  69154. * 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
  69155. */
  69156. interface IAccessor extends IChildRootProperty {
  69157. /**
  69158. * The index of the bufferview
  69159. */
  69160. bufferView?: number;
  69161. /**
  69162. * The offset relative to the start of the bufferView in bytes
  69163. */
  69164. byteOffset?: number;
  69165. /**
  69166. * The datatype of components in the attribute
  69167. */
  69168. componentType: AccessorComponentType;
  69169. /**
  69170. * Specifies whether integer data values should be normalized
  69171. */
  69172. normalized?: boolean;
  69173. /**
  69174. * The number of attributes referenced by this accessor
  69175. */
  69176. count: number;
  69177. /**
  69178. * Specifies if the attribute is a scalar, vector, or matrix
  69179. */
  69180. type: AccessorType;
  69181. /**
  69182. * Maximum value of each component in this attribute
  69183. */
  69184. max?: number[];
  69185. /**
  69186. * Minimum value of each component in this attribute
  69187. */
  69188. min?: number[];
  69189. /**
  69190. * Sparse storage of attributes that deviate from their initialization value
  69191. */
  69192. sparse?: IAccessorSparse;
  69193. }
  69194. /**
  69195. * Targets an animation's sampler at a node's property
  69196. */
  69197. interface IAnimationChannel extends IProperty {
  69198. /**
  69199. * The index of a sampler in this animation used to compute the value for the target
  69200. */
  69201. sampler: number;
  69202. /**
  69203. * The index of the node and TRS property to target
  69204. */
  69205. target: IAnimationChannelTarget;
  69206. }
  69207. /**
  69208. * The index of the node and TRS property that an animation channel targets
  69209. */
  69210. interface IAnimationChannelTarget extends IProperty {
  69211. /**
  69212. * The index of the node to target
  69213. */
  69214. node: number;
  69215. /**
  69216. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69217. */
  69218. path: AnimationChannelTargetPath;
  69219. }
  69220. /**
  69221. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69222. */
  69223. interface IAnimationSampler extends IProperty {
  69224. /**
  69225. * The index of an accessor containing keyframe input values, e.g., time
  69226. */
  69227. input: number;
  69228. /**
  69229. * Interpolation algorithm
  69230. */
  69231. interpolation?: AnimationSamplerInterpolation;
  69232. /**
  69233. * The index of an accessor, containing keyframe output values
  69234. */
  69235. output: number;
  69236. }
  69237. /**
  69238. * A keyframe animation
  69239. */
  69240. interface IAnimation extends IChildRootProperty {
  69241. /**
  69242. * An array of channels, each of which targets an animation's sampler at a node's property
  69243. */
  69244. channels: IAnimationChannel[];
  69245. /**
  69246. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69247. */
  69248. samplers: IAnimationSampler[];
  69249. }
  69250. /**
  69251. * Metadata about the glTF asset
  69252. */
  69253. interface IAsset extends IChildRootProperty {
  69254. /**
  69255. * A copyright message suitable for display to credit the content creator
  69256. */
  69257. copyright?: string;
  69258. /**
  69259. * Tool that generated this glTF model. Useful for debugging
  69260. */
  69261. generator?: string;
  69262. /**
  69263. * The glTF version that this asset targets
  69264. */
  69265. version: string;
  69266. /**
  69267. * The minimum glTF version that this asset targets
  69268. */
  69269. minVersion?: string;
  69270. }
  69271. /**
  69272. * A buffer points to binary geometry, animation, or skins
  69273. */
  69274. interface IBuffer extends IChildRootProperty {
  69275. /**
  69276. * 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
  69277. */
  69278. uri?: string;
  69279. /**
  69280. * The length of the buffer in bytes
  69281. */
  69282. byteLength: number;
  69283. }
  69284. /**
  69285. * A view into a buffer generally representing a subset of the buffer
  69286. */
  69287. interface IBufferView extends IChildRootProperty {
  69288. /**
  69289. * The index of the buffer
  69290. */
  69291. buffer: number;
  69292. /**
  69293. * The offset into the buffer in bytes
  69294. */
  69295. byteOffset?: number;
  69296. /**
  69297. * The lenth of the bufferView in bytes
  69298. */
  69299. byteLength: number;
  69300. /**
  69301. * The stride, in bytes
  69302. */
  69303. byteStride?: number;
  69304. }
  69305. /**
  69306. * An orthographic camera containing properties to create an orthographic projection matrix
  69307. */
  69308. interface ICameraOrthographic extends IProperty {
  69309. /**
  69310. * The floating-point horizontal magnification of the view. Must not be zero
  69311. */
  69312. xmag: number;
  69313. /**
  69314. * The floating-point vertical magnification of the view. Must not be zero
  69315. */
  69316. ymag: number;
  69317. /**
  69318. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69319. */
  69320. zfar: number;
  69321. /**
  69322. * The floating-point distance to the near clipping plane
  69323. */
  69324. znear: number;
  69325. }
  69326. /**
  69327. * A perspective camera containing properties to create a perspective projection matrix
  69328. */
  69329. interface ICameraPerspective extends IProperty {
  69330. /**
  69331. * The floating-point aspect ratio of the field of view
  69332. */
  69333. aspectRatio?: number;
  69334. /**
  69335. * The floating-point vertical field of view in radians
  69336. */
  69337. yfov: number;
  69338. /**
  69339. * The floating-point distance to the far clipping plane
  69340. */
  69341. zfar?: number;
  69342. /**
  69343. * The floating-point distance to the near clipping plane
  69344. */
  69345. znear: number;
  69346. }
  69347. /**
  69348. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69349. */
  69350. interface ICamera extends IChildRootProperty {
  69351. /**
  69352. * An orthographic camera containing properties to create an orthographic projection matrix
  69353. */
  69354. orthographic?: ICameraOrthographic;
  69355. /**
  69356. * A perspective camera containing properties to create a perspective projection matrix
  69357. */
  69358. perspective?: ICameraPerspective;
  69359. /**
  69360. * Specifies if the camera uses a perspective or orthographic projection
  69361. */
  69362. type: CameraType;
  69363. }
  69364. /**
  69365. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  69366. */
  69367. interface IImage extends IChildRootProperty {
  69368. /**
  69369. * 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
  69370. */
  69371. uri?: string;
  69372. /**
  69373. * The image's MIME type
  69374. */
  69375. mimeType?: ImageMimeType;
  69376. /**
  69377. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  69378. */
  69379. bufferView?: number;
  69380. }
  69381. /**
  69382. * Material Normal Texture Info
  69383. */
  69384. interface IMaterialNormalTextureInfo extends ITextureInfo {
  69385. /**
  69386. * The scalar multiplier applied to each normal vector of the normal texture
  69387. */
  69388. scale?: number;
  69389. }
  69390. /**
  69391. * Material Occlusion Texture Info
  69392. */
  69393. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  69394. /**
  69395. * A scalar multiplier controlling the amount of occlusion applied
  69396. */
  69397. strength?: number;
  69398. }
  69399. /**
  69400. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  69401. */
  69402. interface IMaterialPbrMetallicRoughness {
  69403. /**
  69404. * The material's base color factor
  69405. */
  69406. baseColorFactor?: number[];
  69407. /**
  69408. * The base color texture
  69409. */
  69410. baseColorTexture?: ITextureInfo;
  69411. /**
  69412. * The metalness of the material
  69413. */
  69414. metallicFactor?: number;
  69415. /**
  69416. * The roughness of the material
  69417. */
  69418. roughnessFactor?: number;
  69419. /**
  69420. * The metallic-roughness texture
  69421. */
  69422. metallicRoughnessTexture?: ITextureInfo;
  69423. }
  69424. /**
  69425. * The material appearance of a primitive
  69426. */
  69427. interface IMaterial extends IChildRootProperty {
  69428. /**
  69429. * 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
  69430. */
  69431. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69432. /**
  69433. * The normal map texture
  69434. */
  69435. normalTexture?: IMaterialNormalTextureInfo;
  69436. /**
  69437. * The occlusion map texture
  69438. */
  69439. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69440. /**
  69441. * The emissive map texture
  69442. */
  69443. emissiveTexture?: ITextureInfo;
  69444. /**
  69445. * 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
  69446. */
  69447. emissiveFactor?: number[];
  69448. /**
  69449. * The alpha rendering mode of the material
  69450. */
  69451. alphaMode?: MaterialAlphaMode;
  69452. /**
  69453. * The alpha cutoff value of the material
  69454. */
  69455. alphaCutoff?: number;
  69456. /**
  69457. * Specifies whether the material is double sided
  69458. */
  69459. doubleSided?: boolean;
  69460. }
  69461. /**
  69462. * Geometry to be rendered with the given material
  69463. */
  69464. interface IMeshPrimitive extends IProperty {
  69465. /**
  69466. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  69467. */
  69468. attributes: {
  69469. [name: string]: number;
  69470. };
  69471. /**
  69472. * The index of the accessor that contains the indices
  69473. */
  69474. indices?: number;
  69475. /**
  69476. * The index of the material to apply to this primitive when rendering
  69477. */
  69478. material?: number;
  69479. /**
  69480. * The type of primitives to render. All valid values correspond to WebGL enums
  69481. */
  69482. mode?: MeshPrimitiveMode;
  69483. /**
  69484. * 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
  69485. */
  69486. targets?: {
  69487. [name: string]: number;
  69488. }[];
  69489. }
  69490. /**
  69491. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  69492. */
  69493. interface IMesh extends IChildRootProperty {
  69494. /**
  69495. * An array of primitives, each defining geometry to be rendered with a material
  69496. */
  69497. primitives: IMeshPrimitive[];
  69498. /**
  69499. * Array of weights to be applied to the Morph Targets
  69500. */
  69501. weights?: number[];
  69502. }
  69503. /**
  69504. * A node in the node hierarchy
  69505. */
  69506. interface INode extends IChildRootProperty {
  69507. /**
  69508. * The index of the camera referenced by this node
  69509. */
  69510. camera?: number;
  69511. /**
  69512. * The indices of this node's children
  69513. */
  69514. children?: number[];
  69515. /**
  69516. * The index of the skin referenced by this node
  69517. */
  69518. skin?: number;
  69519. /**
  69520. * A floating-point 4x4 transformation matrix stored in column-major order
  69521. */
  69522. matrix?: number[];
  69523. /**
  69524. * The index of the mesh in this node
  69525. */
  69526. mesh?: number;
  69527. /**
  69528. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  69529. */
  69530. rotation?: number[];
  69531. /**
  69532. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  69533. */
  69534. scale?: number[];
  69535. /**
  69536. * The node's translation along the x, y, and z axes
  69537. */
  69538. translation?: number[];
  69539. /**
  69540. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  69541. */
  69542. weights?: number[];
  69543. }
  69544. /**
  69545. * Texture sampler properties for filtering and wrapping modes
  69546. */
  69547. interface ISampler extends IChildRootProperty {
  69548. /**
  69549. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69550. */
  69551. magFilter?: TextureMagFilter;
  69552. /**
  69553. * Minification filter. All valid values correspond to WebGL enums
  69554. */
  69555. minFilter?: TextureMinFilter;
  69556. /**
  69557. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69558. */
  69559. wrapS?: TextureWrapMode;
  69560. /**
  69561. * T (V) wrapping mode. All valid values correspond to WebGL enums
  69562. */
  69563. wrapT?: TextureWrapMode;
  69564. }
  69565. /**
  69566. * The root nodes of a scene
  69567. */
  69568. interface IScene extends IChildRootProperty {
  69569. /**
  69570. * The indices of each root node
  69571. */
  69572. nodes: number[];
  69573. }
  69574. /**
  69575. * Joints and matrices defining a skin
  69576. */
  69577. interface ISkin extends IChildRootProperty {
  69578. /**
  69579. * 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
  69580. */
  69581. inverseBindMatrices?: number;
  69582. /**
  69583. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  69584. */
  69585. skeleton?: number;
  69586. /**
  69587. * 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)
  69588. */
  69589. joints: number[];
  69590. }
  69591. /**
  69592. * A texture and its sampler
  69593. */
  69594. interface ITexture extends IChildRootProperty {
  69595. /**
  69596. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  69597. */
  69598. sampler?: number;
  69599. /**
  69600. * The index of the image used by this texture
  69601. */
  69602. source: number;
  69603. }
  69604. /**
  69605. * Reference to a texture
  69606. */
  69607. interface ITextureInfo extends IProperty {
  69608. /**
  69609. * The index of the texture
  69610. */
  69611. index: number;
  69612. /**
  69613. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  69614. */
  69615. texCoord?: number;
  69616. }
  69617. /**
  69618. * The root object for a glTF asset
  69619. */
  69620. interface IGLTF extends IProperty {
  69621. /**
  69622. * An array of accessors. An accessor is a typed view into a bufferView
  69623. */
  69624. accessors?: IAccessor[];
  69625. /**
  69626. * An array of keyframe animations
  69627. */
  69628. animations?: IAnimation[];
  69629. /**
  69630. * Metadata about the glTF asset
  69631. */
  69632. asset: IAsset;
  69633. /**
  69634. * An array of buffers. A buffer points to binary geometry, animation, or skins
  69635. */
  69636. buffers?: IBuffer[];
  69637. /**
  69638. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  69639. */
  69640. bufferViews?: IBufferView[];
  69641. /**
  69642. * An array of cameras
  69643. */
  69644. cameras?: ICamera[];
  69645. /**
  69646. * Names of glTF extensions used somewhere in this asset
  69647. */
  69648. extensionsUsed?: string[];
  69649. /**
  69650. * Names of glTF extensions required to properly load this asset
  69651. */
  69652. extensionsRequired?: string[];
  69653. /**
  69654. * An array of images. An image defines data used to create a texture
  69655. */
  69656. images?: IImage[];
  69657. /**
  69658. * An array of materials. A material defines the appearance of a primitive
  69659. */
  69660. materials?: IMaterial[];
  69661. /**
  69662. * An array of meshes. A mesh is a set of primitives to be rendered
  69663. */
  69664. meshes?: IMesh[];
  69665. /**
  69666. * An array of nodes
  69667. */
  69668. nodes?: INode[];
  69669. /**
  69670. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  69671. */
  69672. samplers?: ISampler[];
  69673. /**
  69674. * The index of the default scene
  69675. */
  69676. scene?: number;
  69677. /**
  69678. * An array of scenes
  69679. */
  69680. scenes?: IScene[];
  69681. /**
  69682. * An array of skins. A skin is defined by joints and matrices
  69683. */
  69684. skins?: ISkin[];
  69685. /**
  69686. * An array of textures
  69687. */
  69688. textures?: ITexture[];
  69689. }
  69690. /**
  69691. * The glTF validation results
  69692. */
  69693. interface IGLTFValidationResults {
  69694. info: {
  69695. generator: string;
  69696. hasAnimations: boolean;
  69697. hasDefaultScene: boolean;
  69698. hasMaterials: boolean;
  69699. hasMorphTargets: boolean;
  69700. hasSkins: boolean;
  69701. hasTextures: boolean;
  69702. maxAttributesUsed: number;
  69703. primitivesCount: number
  69704. };
  69705. issues: {
  69706. messages: Array<string>;
  69707. numErrors: number;
  69708. numHints: number;
  69709. numInfos: number;
  69710. numWarnings: number;
  69711. truncated: boolean
  69712. };
  69713. mimeType: string;
  69714. uri: string;
  69715. validatedAt: string;
  69716. validatorVersion: string;
  69717. }
  69718. /**
  69719. * The glTF validation options
  69720. */
  69721. interface IGLTFValidationOptions {
  69722. uri?: string;
  69723. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  69724. validateAccessorData?: boolean;
  69725. maxIssues?: number;
  69726. ignoredIssues?: Array<string>;
  69727. severityOverrides?: Object;
  69728. }
  69729. /**
  69730. * The glTF validator object
  69731. */
  69732. interface IGLTFValidator {
  69733. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69734. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  69735. }
  69736. }
  69737. declare module BABYLON {
  69738. /** @hidden */
  69739. export var cellPixelShader: {
  69740. name: string;
  69741. shader: string;
  69742. };
  69743. }
  69744. declare module BABYLON {
  69745. /** @hidden */
  69746. export var cellVertexShader: {
  69747. name: string;
  69748. shader: string;
  69749. };
  69750. }
  69751. declare module BABYLON {
  69752. export class CellMaterial extends BABYLON.PushMaterial {
  69753. private _diffuseTexture;
  69754. diffuseTexture: BABYLON.BaseTexture;
  69755. diffuseColor: BABYLON.Color3;
  69756. _computeHighLevel: boolean;
  69757. computeHighLevel: boolean;
  69758. private _disableLighting;
  69759. disableLighting: boolean;
  69760. private _maxSimultaneousLights;
  69761. maxSimultaneousLights: number;
  69762. private _renderId;
  69763. constructor(name: string, scene: BABYLON.Scene);
  69764. needAlphaBlending(): boolean;
  69765. needAlphaTesting(): boolean;
  69766. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69767. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69768. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69769. getAnimatables(): BABYLON.IAnimatable[];
  69770. getActiveTextures(): BABYLON.BaseTexture[];
  69771. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69772. dispose(forceDisposeEffect?: boolean): void;
  69773. getClassName(): string;
  69774. clone(name: string): CellMaterial;
  69775. serialize(): any;
  69776. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  69777. }
  69778. }
  69779. declare module BABYLON {
  69780. export class CustomShaderStructure {
  69781. FragmentStore: string;
  69782. VertexStore: string;
  69783. constructor();
  69784. }
  69785. export class ShaderSpecialParts {
  69786. constructor();
  69787. Fragment_Begin: string;
  69788. Fragment_Definitions: string;
  69789. Fragment_MainBegin: string;
  69790. Fragment_Custom_Diffuse: string;
  69791. Fragment_Before_Lights: string;
  69792. Fragment_Before_Fog: string;
  69793. Fragment_Custom_Alpha: string;
  69794. Fragment_Before_FragColor: string;
  69795. Vertex_Begin: string;
  69796. Vertex_Definitions: string;
  69797. Vertex_MainBegin: string;
  69798. Vertex_Before_PositionUpdated: string;
  69799. Vertex_Before_NormalUpdated: string;
  69800. Vertex_MainEnd: string;
  69801. }
  69802. export class CustomMaterial extends BABYLON.StandardMaterial {
  69803. static ShaderIndexer: number;
  69804. CustomParts: ShaderSpecialParts;
  69805. _isCreatedShader: boolean;
  69806. _createdShaderName: string;
  69807. _customUniform: string[];
  69808. _newUniforms: string[];
  69809. _newUniformInstances: any[];
  69810. _newSamplerInstances: BABYLON.Texture[];
  69811. FragmentShader: string;
  69812. VertexShader: string;
  69813. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69814. ReviewUniform(name: string, arr: string[]): string[];
  69815. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  69816. constructor(name: string, scene: BABYLON.Scene);
  69817. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  69818. Fragment_Begin(shaderPart: string): CustomMaterial;
  69819. Fragment_Definitions(shaderPart: string): CustomMaterial;
  69820. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  69821. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  69822. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  69823. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  69824. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  69825. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  69826. Vertex_Begin(shaderPart: string): CustomMaterial;
  69827. Vertex_Definitions(shaderPart: string): CustomMaterial;
  69828. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  69829. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  69830. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  69831. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  69832. }
  69833. }
  69834. declare module BABYLON {
  69835. export class ShaderAlebdoParts {
  69836. constructor();
  69837. Fragment_Begin: string;
  69838. Fragment_Definitions: string;
  69839. Fragment_MainBegin: string;
  69840. Fragment_Custom_Albedo: string;
  69841. Fragment_Before_Lights: string;
  69842. Fragment_Custom_MetallicRoughness: string;
  69843. Fragment_Custom_MicroSurface: string;
  69844. Fragment_Before_Fog: string;
  69845. Fragment_Custom_Alpha: string;
  69846. Fragment_Before_FragColor: string;
  69847. Vertex_Begin: string;
  69848. Vertex_Definitions: string;
  69849. Vertex_MainBegin: string;
  69850. Vertex_Before_PositionUpdated: string;
  69851. Vertex_Before_NormalUpdated: string;
  69852. Vertex_MainEnd: string;
  69853. }
  69854. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  69855. static ShaderIndexer: number;
  69856. CustomParts: ShaderAlebdoParts;
  69857. _isCreatedShader: boolean;
  69858. _createdShaderName: string;
  69859. _customUniform: string[];
  69860. _newUniforms: string[];
  69861. _newUniformInstances: any[];
  69862. _newSamplerInstances: BABYLON.Texture[];
  69863. FragmentShader: string;
  69864. VertexShader: string;
  69865. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  69866. ReviewUniform(name: string, arr: string[]): string[];
  69867. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  69868. constructor(name: string, scene: BABYLON.Scene);
  69869. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  69870. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  69871. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  69872. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  69873. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  69874. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  69875. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  69876. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  69877. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  69878. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  69879. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  69880. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  69881. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  69882. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  69883. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  69884. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  69885. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  69886. }
  69887. }
  69888. declare module BABYLON {
  69889. /** @hidden */
  69890. export var firePixelShader: {
  69891. name: string;
  69892. shader: string;
  69893. };
  69894. }
  69895. declare module BABYLON {
  69896. /** @hidden */
  69897. export var fireVertexShader: {
  69898. name: string;
  69899. shader: string;
  69900. };
  69901. }
  69902. declare module BABYLON {
  69903. export class FireMaterial extends BABYLON.PushMaterial {
  69904. private _diffuseTexture;
  69905. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69906. private _distortionTexture;
  69907. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69908. private _opacityTexture;
  69909. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  69910. diffuseColor: BABYLON.Color3;
  69911. speed: number;
  69912. private _scaledDiffuse;
  69913. private _renderId;
  69914. private _lastTime;
  69915. constructor(name: string, scene: BABYLON.Scene);
  69916. needAlphaBlending(): boolean;
  69917. needAlphaTesting(): boolean;
  69918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69921. getAnimatables(): BABYLON.IAnimatable[];
  69922. getActiveTextures(): BABYLON.BaseTexture[];
  69923. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69924. getClassName(): string;
  69925. dispose(forceDisposeEffect?: boolean): void;
  69926. clone(name: string): FireMaterial;
  69927. serialize(): any;
  69928. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  69929. }
  69930. }
  69931. declare module BABYLON {
  69932. /** @hidden */
  69933. export var furPixelShader: {
  69934. name: string;
  69935. shader: string;
  69936. };
  69937. }
  69938. declare module BABYLON {
  69939. /** @hidden */
  69940. export var furVertexShader: {
  69941. name: string;
  69942. shader: string;
  69943. };
  69944. }
  69945. declare module BABYLON {
  69946. export class FurMaterial extends BABYLON.PushMaterial {
  69947. private _diffuseTexture;
  69948. diffuseTexture: BABYLON.BaseTexture;
  69949. private _heightTexture;
  69950. heightTexture: BABYLON.BaseTexture;
  69951. diffuseColor: BABYLON.Color3;
  69952. furLength: number;
  69953. furAngle: number;
  69954. furColor: BABYLON.Color3;
  69955. furOffset: number;
  69956. furSpacing: number;
  69957. furGravity: BABYLON.Vector3;
  69958. furSpeed: number;
  69959. furDensity: number;
  69960. furOcclusion: number;
  69961. furTexture: BABYLON.DynamicTexture;
  69962. private _disableLighting;
  69963. disableLighting: boolean;
  69964. private _maxSimultaneousLights;
  69965. maxSimultaneousLights: number;
  69966. highLevelFur: boolean;
  69967. _meshes: BABYLON.AbstractMesh[];
  69968. private _renderId;
  69969. private _furTime;
  69970. constructor(name: string, scene: BABYLON.Scene);
  69971. furTime: number;
  69972. needAlphaBlending(): boolean;
  69973. needAlphaTesting(): boolean;
  69974. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69975. updateFur(): void;
  69976. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69977. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69978. getAnimatables(): BABYLON.IAnimatable[];
  69979. getActiveTextures(): BABYLON.BaseTexture[];
  69980. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69981. dispose(forceDisposeEffect?: boolean): void;
  69982. clone(name: string): FurMaterial;
  69983. serialize(): any;
  69984. getClassName(): string;
  69985. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  69986. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  69987. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  69988. }
  69989. }
  69990. declare module BABYLON {
  69991. /** @hidden */
  69992. export var gradientPixelShader: {
  69993. name: string;
  69994. shader: string;
  69995. };
  69996. }
  69997. declare module BABYLON {
  69998. /** @hidden */
  69999. export var gradientVertexShader: {
  70000. name: string;
  70001. shader: string;
  70002. };
  70003. }
  70004. declare module BABYLON {
  70005. export class GradientMaterial extends BABYLON.PushMaterial {
  70006. private _maxSimultaneousLights;
  70007. maxSimultaneousLights: number;
  70008. topColor: BABYLON.Color3;
  70009. topColorAlpha: number;
  70010. bottomColor: BABYLON.Color3;
  70011. bottomColorAlpha: number;
  70012. offset: number;
  70013. scale: number;
  70014. smoothness: number;
  70015. private _disableLighting;
  70016. disableLighting: boolean;
  70017. private _renderId;
  70018. constructor(name: string, scene: BABYLON.Scene);
  70019. needAlphaBlending(): boolean;
  70020. needAlphaTesting(): boolean;
  70021. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70022. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70023. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70024. getAnimatables(): BABYLON.IAnimatable[];
  70025. dispose(forceDisposeEffect?: boolean): void;
  70026. clone(name: string): GradientMaterial;
  70027. serialize(): any;
  70028. getClassName(): string;
  70029. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70030. }
  70031. }
  70032. declare module BABYLON {
  70033. /** @hidden */
  70034. export var gridPixelShader: {
  70035. name: string;
  70036. shader: string;
  70037. };
  70038. }
  70039. declare module BABYLON {
  70040. /** @hidden */
  70041. export var gridVertexShader: {
  70042. name: string;
  70043. shader: string;
  70044. };
  70045. }
  70046. declare module BABYLON {
  70047. /**
  70048. * The grid materials allows you to wrap any shape with a grid.
  70049. * Colors are customizable.
  70050. */
  70051. export class GridMaterial extends BABYLON.PushMaterial {
  70052. /**
  70053. * Main color of the grid (e.g. between lines)
  70054. */
  70055. mainColor: BABYLON.Color3;
  70056. /**
  70057. * Color of the grid lines.
  70058. */
  70059. lineColor: BABYLON.Color3;
  70060. /**
  70061. * The scale of the grid compared to unit.
  70062. */
  70063. gridRatio: number;
  70064. /**
  70065. * Allows setting an offset for the grid lines.
  70066. */
  70067. gridOffset: BABYLON.Vector3;
  70068. /**
  70069. * The frequency of thicker lines.
  70070. */
  70071. majorUnitFrequency: number;
  70072. /**
  70073. * The visibility of minor units in the grid.
  70074. */
  70075. minorUnitVisibility: number;
  70076. /**
  70077. * The grid opacity outside of the lines.
  70078. */
  70079. opacity: number;
  70080. /**
  70081. * Determine RBG output is premultiplied by alpha value.
  70082. */
  70083. preMultiplyAlpha: boolean;
  70084. private _opacityTexture;
  70085. opacityTexture: BABYLON.BaseTexture;
  70086. private _gridControl;
  70087. private _renderId;
  70088. /**
  70089. * constructor
  70090. * @param name The name given to the material in order to identify it afterwards.
  70091. * @param scene The scene the material is used in.
  70092. */
  70093. constructor(name: string, scene: BABYLON.Scene);
  70094. /**
  70095. * Returns wehter or not the grid requires alpha blending.
  70096. */
  70097. needAlphaBlending(): boolean;
  70098. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70099. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70100. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70101. /**
  70102. * Dispose the material and its associated resources.
  70103. * @param forceDisposeEffect will also dispose the used effect when true
  70104. */
  70105. dispose(forceDisposeEffect?: boolean): void;
  70106. clone(name: string): GridMaterial;
  70107. serialize(): any;
  70108. getClassName(): string;
  70109. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70110. }
  70111. }
  70112. declare module BABYLON {
  70113. /** @hidden */
  70114. export var lavaPixelShader: {
  70115. name: string;
  70116. shader: string;
  70117. };
  70118. }
  70119. declare module BABYLON {
  70120. /** @hidden */
  70121. export var lavaVertexShader: {
  70122. name: string;
  70123. shader: string;
  70124. };
  70125. }
  70126. declare module BABYLON {
  70127. export class LavaMaterial extends BABYLON.PushMaterial {
  70128. private _diffuseTexture;
  70129. diffuseTexture: BABYLON.BaseTexture;
  70130. noiseTexture: BABYLON.BaseTexture;
  70131. fogColor: BABYLON.Color3;
  70132. speed: number;
  70133. movingSpeed: number;
  70134. lowFrequencySpeed: number;
  70135. fogDensity: number;
  70136. private _lastTime;
  70137. diffuseColor: BABYLON.Color3;
  70138. private _disableLighting;
  70139. disableLighting: boolean;
  70140. private _unlit;
  70141. unlit: boolean;
  70142. private _maxSimultaneousLights;
  70143. maxSimultaneousLights: number;
  70144. private _scaledDiffuse;
  70145. private _renderId;
  70146. constructor(name: string, scene: BABYLON.Scene);
  70147. needAlphaBlending(): boolean;
  70148. needAlphaTesting(): boolean;
  70149. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70150. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70151. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70152. getAnimatables(): BABYLON.IAnimatable[];
  70153. getActiveTextures(): BABYLON.BaseTexture[];
  70154. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70155. dispose(forceDisposeEffect?: boolean): void;
  70156. clone(name: string): LavaMaterial;
  70157. serialize(): any;
  70158. getClassName(): string;
  70159. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70160. }
  70161. }
  70162. declare module BABYLON {
  70163. /** @hidden */
  70164. export var mixPixelShader: {
  70165. name: string;
  70166. shader: string;
  70167. };
  70168. }
  70169. declare module BABYLON {
  70170. /** @hidden */
  70171. export var mixVertexShader: {
  70172. name: string;
  70173. shader: string;
  70174. };
  70175. }
  70176. declare module BABYLON {
  70177. export class MixMaterial extends BABYLON.PushMaterial {
  70178. /**
  70179. * Mix textures
  70180. */
  70181. private _mixTexture1;
  70182. mixTexture1: BABYLON.BaseTexture;
  70183. private _mixTexture2;
  70184. mixTexture2: BABYLON.BaseTexture;
  70185. /**
  70186. * Diffuse textures
  70187. */
  70188. private _diffuseTexture1;
  70189. diffuseTexture1: BABYLON.Texture;
  70190. private _diffuseTexture2;
  70191. diffuseTexture2: BABYLON.Texture;
  70192. private _diffuseTexture3;
  70193. diffuseTexture3: BABYLON.Texture;
  70194. private _diffuseTexture4;
  70195. diffuseTexture4: BABYLON.Texture;
  70196. private _diffuseTexture5;
  70197. diffuseTexture5: BABYLON.Texture;
  70198. private _diffuseTexture6;
  70199. diffuseTexture6: BABYLON.Texture;
  70200. private _diffuseTexture7;
  70201. diffuseTexture7: BABYLON.Texture;
  70202. private _diffuseTexture8;
  70203. diffuseTexture8: BABYLON.Texture;
  70204. /**
  70205. * Uniforms
  70206. */
  70207. diffuseColor: BABYLON.Color3;
  70208. specularColor: BABYLON.Color3;
  70209. specularPower: number;
  70210. private _disableLighting;
  70211. disableLighting: boolean;
  70212. private _maxSimultaneousLights;
  70213. maxSimultaneousLights: number;
  70214. private _renderId;
  70215. constructor(name: string, scene: BABYLON.Scene);
  70216. needAlphaBlending(): boolean;
  70217. needAlphaTesting(): boolean;
  70218. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70219. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70220. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70221. getAnimatables(): BABYLON.IAnimatable[];
  70222. getActiveTextures(): BABYLON.BaseTexture[];
  70223. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70224. dispose(forceDisposeEffect?: boolean): void;
  70225. clone(name: string): MixMaterial;
  70226. serialize(): any;
  70227. getClassName(): string;
  70228. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70229. }
  70230. }
  70231. declare module BABYLON {
  70232. /** @hidden */
  70233. export var normalPixelShader: {
  70234. name: string;
  70235. shader: string;
  70236. };
  70237. }
  70238. declare module BABYLON {
  70239. /** @hidden */
  70240. export var normalVertexShader: {
  70241. name: string;
  70242. shader: string;
  70243. };
  70244. }
  70245. declare module BABYLON {
  70246. export class NormalMaterial extends BABYLON.PushMaterial {
  70247. private _diffuseTexture;
  70248. diffuseTexture: BABYLON.BaseTexture;
  70249. diffuseColor: BABYLON.Color3;
  70250. private _disableLighting;
  70251. disableLighting: boolean;
  70252. private _maxSimultaneousLights;
  70253. maxSimultaneousLights: number;
  70254. private _renderId;
  70255. constructor(name: string, scene: BABYLON.Scene);
  70256. needAlphaBlending(): boolean;
  70257. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70258. needAlphaTesting(): boolean;
  70259. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70261. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70262. getAnimatables(): BABYLON.IAnimatable[];
  70263. getActiveTextures(): BABYLON.BaseTexture[];
  70264. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70265. dispose(forceDisposeEffect?: boolean): void;
  70266. clone(name: string): NormalMaterial;
  70267. serialize(): any;
  70268. getClassName(): string;
  70269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export var shadowOnlyPixelShader: {
  70275. name: string;
  70276. shader: string;
  70277. };
  70278. }
  70279. declare module BABYLON {
  70280. /** @hidden */
  70281. export var shadowOnlyVertexShader: {
  70282. name: string;
  70283. shader: string;
  70284. };
  70285. }
  70286. declare module BABYLON {
  70287. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70288. private _renderId;
  70289. private _activeLight;
  70290. constructor(name: string, scene: BABYLON.Scene);
  70291. shadowColor: BABYLON.Color3;
  70292. needAlphaBlending(): boolean;
  70293. needAlphaTesting(): boolean;
  70294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70295. activeLight: BABYLON.IShadowLight;
  70296. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70297. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70298. clone(name: string): ShadowOnlyMaterial;
  70299. serialize(): any;
  70300. getClassName(): string;
  70301. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /** @hidden */
  70306. export var simplePixelShader: {
  70307. name: string;
  70308. shader: string;
  70309. };
  70310. }
  70311. declare module BABYLON {
  70312. /** @hidden */
  70313. export var simpleVertexShader: {
  70314. name: string;
  70315. shader: string;
  70316. };
  70317. }
  70318. declare module BABYLON {
  70319. export class SimpleMaterial extends BABYLON.PushMaterial {
  70320. private _diffuseTexture;
  70321. diffuseTexture: BABYLON.BaseTexture;
  70322. diffuseColor: BABYLON.Color3;
  70323. private _disableLighting;
  70324. disableLighting: boolean;
  70325. private _maxSimultaneousLights;
  70326. maxSimultaneousLights: number;
  70327. private _renderId;
  70328. constructor(name: string, scene: BABYLON.Scene);
  70329. needAlphaBlending(): boolean;
  70330. needAlphaTesting(): boolean;
  70331. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70334. getAnimatables(): BABYLON.IAnimatable[];
  70335. getActiveTextures(): BABYLON.BaseTexture[];
  70336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70337. dispose(forceDisposeEffect?: boolean): void;
  70338. clone(name: string): SimpleMaterial;
  70339. serialize(): any;
  70340. getClassName(): string;
  70341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70342. }
  70343. }
  70344. declare module BABYLON {
  70345. /** @hidden */
  70346. export var skyPixelShader: {
  70347. name: string;
  70348. shader: string;
  70349. };
  70350. }
  70351. declare module BABYLON {
  70352. /** @hidden */
  70353. export var skyVertexShader: {
  70354. name: string;
  70355. shader: string;
  70356. };
  70357. }
  70358. declare module BABYLON {
  70359. /**
  70360. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  70361. * @see https://doc.babylonjs.com/extensions/sky
  70362. */
  70363. export class SkyMaterial extends BABYLON.PushMaterial {
  70364. /**
  70365. * Defines the overall luminance of sky in interval ]0, 1[.
  70366. */
  70367. luminance: number;
  70368. /**
  70369. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  70370. */
  70371. turbidity: number;
  70372. /**
  70373. * Defines the sky appearance (light intensity).
  70374. */
  70375. rayleigh: number;
  70376. /**
  70377. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  70378. */
  70379. mieCoefficient: number;
  70380. /**
  70381. * Defines the amount of haze particles following the Mie scattering theory.
  70382. */
  70383. mieDirectionalG: number;
  70384. /**
  70385. * Defines the distance of the sun according to the active scene camera.
  70386. */
  70387. distance: number;
  70388. /**
  70389. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  70390. * "inclined".
  70391. */
  70392. inclination: number;
  70393. /**
  70394. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  70395. * an object direction and a reference direction.
  70396. */
  70397. azimuth: number;
  70398. /**
  70399. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  70400. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  70401. */
  70402. sunPosition: BABYLON.Vector3;
  70403. /**
  70404. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  70405. * .sunPosition property.
  70406. */
  70407. useSunPosition: boolean;
  70408. /**
  70409. * Defines an offset vector used to get a horizon offset.
  70410. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  70411. */
  70412. cameraOffset: BABYLON.Vector3;
  70413. private _cameraPosition;
  70414. private _renderId;
  70415. /**
  70416. * Instantiates a new sky material.
  70417. * This material allows to create dynamic and texture free
  70418. * effects for skyboxes by taking care of the atmosphere state.
  70419. * @see https://doc.babylonjs.com/extensions/sky
  70420. * @param name Define the name of the material in the scene
  70421. * @param scene Define the scene the material belong to
  70422. */
  70423. constructor(name: string, scene: BABYLON.Scene);
  70424. /**
  70425. * Specifies if the material will require alpha blending
  70426. * @returns a boolean specifying if alpha blending is needed
  70427. */
  70428. needAlphaBlending(): boolean;
  70429. /**
  70430. * Specifies if this material should be rendered in alpha test mode
  70431. * @returns false as the sky material doesn't need alpha testing.
  70432. */
  70433. needAlphaTesting(): boolean;
  70434. /**
  70435. * Get the texture used for alpha test purpose.
  70436. * @returns null as the sky material has no texture.
  70437. */
  70438. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70439. /**
  70440. * Get if the submesh is ready to be used and all its information available.
  70441. * Child classes can use it to update shaders
  70442. * @param mesh defines the mesh to check
  70443. * @param subMesh defines which submesh to check
  70444. * @param useInstances specifies that instances should be used
  70445. * @returns a boolean indicating that the submesh is ready or not
  70446. */
  70447. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70448. /**
  70449. * Binds the submesh to this material by preparing the effect and shader to draw
  70450. * @param world defines the world transformation matrix
  70451. * @param mesh defines the mesh containing the submesh
  70452. * @param subMesh defines the submesh to bind the material to
  70453. */
  70454. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70455. /**
  70456. * Get the list of animatables in the material.
  70457. * @returns the list of animatables object used in the material
  70458. */
  70459. getAnimatables(): BABYLON.IAnimatable[];
  70460. /**
  70461. * Disposes the material
  70462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70463. */
  70464. dispose(forceDisposeEffect?: boolean): void;
  70465. /**
  70466. * Makes a duplicate of the material, and gives it a new name
  70467. * @param name defines the new name for the duplicated material
  70468. * @returns the cloned material
  70469. */
  70470. clone(name: string): SkyMaterial;
  70471. /**
  70472. * Serializes this material in a JSON representation
  70473. * @returns the serialized material object
  70474. */
  70475. serialize(): any;
  70476. /**
  70477. * Gets the current class name of the material e.g. "SkyMaterial"
  70478. * Mainly use in serialization.
  70479. * @returns the class name
  70480. */
  70481. getClassName(): string;
  70482. /**
  70483. * Creates a sky material from parsed material data
  70484. * @param source defines the JSON representation of the material
  70485. * @param scene defines the hosting scene
  70486. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70487. * @returns a new sky material
  70488. */
  70489. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  70490. }
  70491. }
  70492. declare module BABYLON {
  70493. /** @hidden */
  70494. export var terrainPixelShader: {
  70495. name: string;
  70496. shader: string;
  70497. };
  70498. }
  70499. declare module BABYLON {
  70500. /** @hidden */
  70501. export var terrainVertexShader: {
  70502. name: string;
  70503. shader: string;
  70504. };
  70505. }
  70506. declare module BABYLON {
  70507. export class TerrainMaterial extends BABYLON.PushMaterial {
  70508. private _mixTexture;
  70509. mixTexture: BABYLON.BaseTexture;
  70510. private _diffuseTexture1;
  70511. diffuseTexture1: BABYLON.Texture;
  70512. private _diffuseTexture2;
  70513. diffuseTexture2: BABYLON.Texture;
  70514. private _diffuseTexture3;
  70515. diffuseTexture3: BABYLON.Texture;
  70516. private _bumpTexture1;
  70517. bumpTexture1: BABYLON.Texture;
  70518. private _bumpTexture2;
  70519. bumpTexture2: BABYLON.Texture;
  70520. private _bumpTexture3;
  70521. bumpTexture3: BABYLON.Texture;
  70522. diffuseColor: BABYLON.Color3;
  70523. specularColor: BABYLON.Color3;
  70524. specularPower: number;
  70525. private _disableLighting;
  70526. disableLighting: boolean;
  70527. private _maxSimultaneousLights;
  70528. maxSimultaneousLights: number;
  70529. private _renderId;
  70530. constructor(name: string, scene: BABYLON.Scene);
  70531. needAlphaBlending(): boolean;
  70532. needAlphaTesting(): boolean;
  70533. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70536. getAnimatables(): BABYLON.IAnimatable[];
  70537. getActiveTextures(): BABYLON.BaseTexture[];
  70538. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70539. dispose(forceDisposeEffect?: boolean): void;
  70540. clone(name: string): TerrainMaterial;
  70541. serialize(): any;
  70542. getClassName(): string;
  70543. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  70544. }
  70545. }
  70546. declare module BABYLON {
  70547. /** @hidden */
  70548. export var triplanarPixelShader: {
  70549. name: string;
  70550. shader: string;
  70551. };
  70552. }
  70553. declare module BABYLON {
  70554. /** @hidden */
  70555. export var triplanarVertexShader: {
  70556. name: string;
  70557. shader: string;
  70558. };
  70559. }
  70560. declare module BABYLON {
  70561. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  70562. mixTexture: BABYLON.BaseTexture;
  70563. private _diffuseTextureX;
  70564. diffuseTextureX: BABYLON.BaseTexture;
  70565. private _diffuseTextureY;
  70566. diffuseTextureY: BABYLON.BaseTexture;
  70567. private _diffuseTextureZ;
  70568. diffuseTextureZ: BABYLON.BaseTexture;
  70569. private _normalTextureX;
  70570. normalTextureX: BABYLON.BaseTexture;
  70571. private _normalTextureY;
  70572. normalTextureY: BABYLON.BaseTexture;
  70573. private _normalTextureZ;
  70574. normalTextureZ: BABYLON.BaseTexture;
  70575. tileSize: number;
  70576. diffuseColor: BABYLON.Color3;
  70577. specularColor: BABYLON.Color3;
  70578. specularPower: number;
  70579. private _disableLighting;
  70580. disableLighting: boolean;
  70581. private _maxSimultaneousLights;
  70582. maxSimultaneousLights: number;
  70583. private _renderId;
  70584. constructor(name: string, scene: BABYLON.Scene);
  70585. needAlphaBlending(): boolean;
  70586. needAlphaTesting(): boolean;
  70587. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70588. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70589. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70590. getAnimatables(): BABYLON.IAnimatable[];
  70591. getActiveTextures(): BABYLON.BaseTexture[];
  70592. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70593. dispose(forceDisposeEffect?: boolean): void;
  70594. clone(name: string): TriPlanarMaterial;
  70595. serialize(): any;
  70596. getClassName(): string;
  70597. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  70598. }
  70599. }
  70600. declare module BABYLON {
  70601. /** @hidden */
  70602. export var waterPixelShader: {
  70603. name: string;
  70604. shader: string;
  70605. };
  70606. }
  70607. declare module BABYLON {
  70608. /** @hidden */
  70609. export var waterVertexShader: {
  70610. name: string;
  70611. shader: string;
  70612. };
  70613. }
  70614. declare module BABYLON {
  70615. export class WaterMaterial extends BABYLON.PushMaterial {
  70616. renderTargetSize: BABYLON.Vector2;
  70617. private _bumpTexture;
  70618. bumpTexture: BABYLON.BaseTexture;
  70619. diffuseColor: BABYLON.Color3;
  70620. specularColor: BABYLON.Color3;
  70621. specularPower: number;
  70622. private _disableLighting;
  70623. disableLighting: boolean;
  70624. private _maxSimultaneousLights;
  70625. maxSimultaneousLights: number;
  70626. /**
  70627. * @param {number}: Represents the wind force
  70628. */
  70629. windForce: number;
  70630. /**
  70631. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  70632. */
  70633. windDirection: BABYLON.Vector2;
  70634. /**
  70635. * @param {number}: Wave height, represents the height of the waves
  70636. */
  70637. waveHeight: number;
  70638. /**
  70639. * @param {number}: Bump height, represents the bump height related to the bump map
  70640. */
  70641. bumpHeight: number;
  70642. /**
  70643. * @param {boolean}: Add a smaller moving bump to less steady waves.
  70644. */
  70645. private _bumpSuperimpose;
  70646. bumpSuperimpose: boolean;
  70647. /**
  70648. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  70649. */
  70650. private _fresnelSeparate;
  70651. fresnelSeparate: boolean;
  70652. /**
  70653. * @param {boolean}: bump Waves modify the reflection.
  70654. */
  70655. private _bumpAffectsReflection;
  70656. bumpAffectsReflection: boolean;
  70657. /**
  70658. * @param {number}: The water color blended with the refraction (near)
  70659. */
  70660. waterColor: BABYLON.Color3;
  70661. /**
  70662. * @param {number}: The blend factor related to the water color
  70663. */
  70664. colorBlendFactor: number;
  70665. /**
  70666. * @param {number}: The water color blended with the reflection (far)
  70667. */
  70668. waterColor2: BABYLON.Color3;
  70669. /**
  70670. * @param {number}: The blend factor related to the water color (reflection, far)
  70671. */
  70672. colorBlendFactor2: number;
  70673. /**
  70674. * @param {number}: Represents the maximum length of a wave
  70675. */
  70676. waveLength: number;
  70677. /**
  70678. * @param {number}: Defines the waves speed
  70679. */
  70680. waveSpeed: number;
  70681. /**
  70682. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  70683. * will avoid calculating useless pixels in the pixel shader of the water material.
  70684. */
  70685. disableClipPlane: boolean;
  70686. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  70687. private _mesh;
  70688. private _refractionRTT;
  70689. private _reflectionRTT;
  70690. private _reflectionTransform;
  70691. private _lastTime;
  70692. private _lastDeltaTime;
  70693. private _renderId;
  70694. private _useLogarithmicDepth;
  70695. private _waitingRenderList;
  70696. private _imageProcessingConfiguration;
  70697. private _imageProcessingObserver;
  70698. /**
  70699. * Gets a boolean indicating that current material needs to register RTT
  70700. */
  70701. readonly hasRenderTargetTextures: boolean;
  70702. /**
  70703. * Constructor
  70704. */
  70705. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  70706. useLogarithmicDepth: boolean;
  70707. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70708. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  70709. addToRenderList(node: any): void;
  70710. enableRenderTargets(enable: boolean): void;
  70711. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  70712. readonly renderTargetsEnabled: boolean;
  70713. needAlphaBlending(): boolean;
  70714. needAlphaTesting(): boolean;
  70715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70718. private _createRenderTargets;
  70719. getAnimatables(): BABYLON.IAnimatable[];
  70720. getActiveTextures(): BABYLON.BaseTexture[];
  70721. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70722. dispose(forceDisposeEffect?: boolean): void;
  70723. clone(name: string): WaterMaterial;
  70724. serialize(): any;
  70725. getClassName(): string;
  70726. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  70727. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  70728. }
  70729. }
  70730. declare module BABYLON {
  70731. /** @hidden */
  70732. export var asciiartPixelShader: {
  70733. name: string;
  70734. shader: string;
  70735. };
  70736. }
  70737. declare module BABYLON {
  70738. /**
  70739. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  70740. *
  70741. * It basically takes care rendering the font front the given font size to a texture.
  70742. * This is used later on in the postprocess.
  70743. */
  70744. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  70745. private _font;
  70746. private _text;
  70747. private _charSize;
  70748. /**
  70749. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70750. */
  70751. readonly charSize: number;
  70752. /**
  70753. * Create a new instance of the Ascii Art FontTexture class
  70754. * @param name the name of the texture
  70755. * @param font the font to use, use the W3C CSS notation
  70756. * @param text the caracter set to use in the rendering.
  70757. * @param scene the scene that owns the texture
  70758. */
  70759. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70760. /**
  70761. * Gets the max char width of a font.
  70762. * @param font the font to use, use the W3C CSS notation
  70763. * @return the max char width
  70764. */
  70765. private getFontWidth;
  70766. /**
  70767. * Gets the max char height of a font.
  70768. * @param font the font to use, use the W3C CSS notation
  70769. * @return the max char height
  70770. */
  70771. private getFontHeight;
  70772. /**
  70773. * Clones the current AsciiArtTexture.
  70774. * @return the clone of the texture.
  70775. */
  70776. clone(): AsciiArtFontTexture;
  70777. /**
  70778. * Parses a json object representing the texture and returns an instance of it.
  70779. * @param source the source JSON representation
  70780. * @param scene the scene to create the texture for
  70781. * @return the parsed texture
  70782. */
  70783. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  70784. }
  70785. /**
  70786. * Option available in the Ascii Art Post Process.
  70787. */
  70788. export interface IAsciiArtPostProcessOptions {
  70789. /**
  70790. * The font to use following the w3c font definition.
  70791. */
  70792. font?: string;
  70793. /**
  70794. * The character set to use in the postprocess.
  70795. */
  70796. characterSet?: string;
  70797. /**
  70798. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70799. * This number is defined between 0 and 1;
  70800. */
  70801. mixToTile?: number;
  70802. /**
  70803. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70804. * This number is defined between 0 and 1;
  70805. */
  70806. mixToNormal?: number;
  70807. }
  70808. /**
  70809. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  70810. *
  70811. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70812. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  70813. */
  70814. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  70815. /**
  70816. * The font texture used to render the char in the post process.
  70817. */
  70818. private _asciiArtFontTexture;
  70819. /**
  70820. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  70821. * This number is defined between 0 and 1;
  70822. */
  70823. mixToTile: number;
  70824. /**
  70825. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  70826. * This number is defined between 0 and 1;
  70827. */
  70828. mixToNormal: number;
  70829. /**
  70830. * Instantiates a new Ascii Art Post Process.
  70831. * @param name the name to give to the postprocess
  70832. * @camera the camera to apply the post process to.
  70833. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  70834. */
  70835. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  70836. }
  70837. }
  70838. declare module BABYLON {
  70839. /** @hidden */
  70840. export var digitalrainPixelShader: {
  70841. name: string;
  70842. shader: string;
  70843. };
  70844. }
  70845. declare module BABYLON {
  70846. /**
  70847. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  70848. *
  70849. * It basically takes care rendering the font front the given font size to a texture.
  70850. * This is used later on in the postprocess.
  70851. */
  70852. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  70853. private _font;
  70854. private _text;
  70855. private _charSize;
  70856. /**
  70857. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  70858. */
  70859. readonly charSize: number;
  70860. /**
  70861. * Create a new instance of the Digital Rain FontTexture class
  70862. * @param name the name of the texture
  70863. * @param font the font to use, use the W3C CSS notation
  70864. * @param text the caracter set to use in the rendering.
  70865. * @param scene the scene that owns the texture
  70866. */
  70867. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  70868. /**
  70869. * Gets the max char width of a font.
  70870. * @param font the font to use, use the W3C CSS notation
  70871. * @return the max char width
  70872. */
  70873. private getFontWidth;
  70874. /**
  70875. * Gets the max char height of a font.
  70876. * @param font the font to use, use the W3C CSS notation
  70877. * @return the max char height
  70878. */
  70879. private getFontHeight;
  70880. /**
  70881. * Clones the current DigitalRainFontTexture.
  70882. * @return the clone of the texture.
  70883. */
  70884. clone(): DigitalRainFontTexture;
  70885. /**
  70886. * Parses a json object representing the texture and returns an instance of it.
  70887. * @param source the source JSON representation
  70888. * @param scene the scene to create the texture for
  70889. * @return the parsed texture
  70890. */
  70891. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  70892. }
  70893. /**
  70894. * Option available in the Digital Rain Post Process.
  70895. */
  70896. export interface IDigitalRainPostProcessOptions {
  70897. /**
  70898. * The font to use following the w3c font definition.
  70899. */
  70900. font?: string;
  70901. /**
  70902. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70903. * This number is defined between 0 and 1;
  70904. */
  70905. mixToTile?: number;
  70906. /**
  70907. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70908. * This number is defined between 0 and 1;
  70909. */
  70910. mixToNormal?: number;
  70911. }
  70912. /**
  70913. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70914. *
  70915. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70916. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  70917. */
  70918. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  70919. /**
  70920. * The font texture used to render the char in the post process.
  70921. */
  70922. private _digitalRainFontTexture;
  70923. /**
  70924. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  70925. * This number is defined between 0 and 1;
  70926. */
  70927. mixToTile: number;
  70928. /**
  70929. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  70930. * This number is defined between 0 and 1;
  70931. */
  70932. mixToNormal: number;
  70933. /**
  70934. * Instantiates a new Digital Rain Post Process.
  70935. * @param name the name to give to the postprocess
  70936. * @camera the camera to apply the post process to.
  70937. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  70938. */
  70939. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  70940. }
  70941. }
  70942. declare module BABYLON {
  70943. /** @hidden */
  70944. export var oceanPostProcessPixelShader: {
  70945. name: string;
  70946. shader: string;
  70947. };
  70948. }
  70949. declare module BABYLON {
  70950. /**
  70951. * Option available in the Ocean Post Process.
  70952. */
  70953. export interface IOceanPostProcessOptions {
  70954. /**
  70955. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70956. */
  70957. reflectionSize?: number | {
  70958. width: number;
  70959. height: number;
  70960. } | {
  70961. ratio: number;
  70962. };
  70963. /**
  70964. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  70965. */
  70966. refractionSize?: number | {
  70967. width: number;
  70968. height: number;
  70969. } | {
  70970. ratio: number;
  70971. };
  70972. }
  70973. /**
  70974. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  70975. *
  70976. * Simmply add it to your scene and let the nerd that lives in you have fun.
  70977. * Example usage:
  70978. * var pp = new OceanPostProcess("myOcean", camera);
  70979. * pp.reflectionEnabled = true;
  70980. * pp.refractionEnabled = true;
  70981. */
  70982. export class OceanPostProcess extends BABYLON.PostProcess {
  70983. /**
  70984. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  70985. */
  70986. /**
  70987. * Sets weither or not the real-time reflection is enabled on the ocean.
  70988. * Is set to true, the reflection mirror texture will be used as reflection texture.
  70989. */
  70990. reflectionEnabled: boolean;
  70991. /**
  70992. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  70993. */
  70994. /**
  70995. * Sets weither or not the real-time refraction is enabled on the ocean.
  70996. * Is set to true, the refraction render target texture will be used as refraction texture.
  70997. */
  70998. refractionEnabled: boolean;
  70999. /**
  71000. * Gets wether or not the post-processes is supported by the running hardware.
  71001. * This requires draw buffer supports.
  71002. */
  71003. readonly isSupported: boolean;
  71004. /**
  71005. * This is the reflection mirror texture used to display reflections on the ocean.
  71006. * By default, render list is empty.
  71007. */
  71008. reflectionTexture: BABYLON.MirrorTexture;
  71009. /**
  71010. * This is the refraction render target texture used to display refraction on the ocean.
  71011. * By default, render list is empty.
  71012. */
  71013. refractionTexture: BABYLON.RenderTargetTexture;
  71014. private _time;
  71015. private _cameraRotation;
  71016. private _cameraViewMatrix;
  71017. private _reflectionEnabled;
  71018. private _refractionEnabled;
  71019. private _geometryRenderer;
  71020. /**
  71021. * Instantiates a new Ocean Post Process.
  71022. * @param name the name to give to the postprocess.
  71023. * @camera the camera to apply the post process to.
  71024. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71025. */
  71026. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71027. /**
  71028. * Returns the appropriate defines according to the current configuration.
  71029. */
  71030. private _getDefines;
  71031. /**
  71032. * Computes the current camera rotation as the shader requires a camera rotation.
  71033. */
  71034. private _computeCameraRotation;
  71035. }
  71036. }
  71037. declare module BABYLON {
  71038. /** @hidden */
  71039. export var brickProceduralTexturePixelShader: {
  71040. name: string;
  71041. shader: string;
  71042. };
  71043. }
  71044. declare module BABYLON {
  71045. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71046. private _numberOfBricksHeight;
  71047. private _numberOfBricksWidth;
  71048. private _jointColor;
  71049. private _brickColor;
  71050. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71051. updateShaderUniforms(): void;
  71052. numberOfBricksHeight: number;
  71053. numberOfBricksWidth: number;
  71054. jointColor: BABYLON.Color3;
  71055. brickColor: BABYLON.Color3;
  71056. /**
  71057. * Serializes this brick procedural texture
  71058. * @returns a serialized brick procedural texture object
  71059. */
  71060. serialize(): any;
  71061. /**
  71062. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71063. * @param parsedTexture defines parsed texture data
  71064. * @param scene defines the current scene
  71065. * @param rootUrl defines the root URL containing brick procedural texture information
  71066. * @returns a parsed Brick Procedural BABYLON.Texture
  71067. */
  71068. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71069. }
  71070. }
  71071. declare module BABYLON {
  71072. /** @hidden */
  71073. export var cloudProceduralTexturePixelShader: {
  71074. name: string;
  71075. shader: string;
  71076. };
  71077. }
  71078. declare module BABYLON {
  71079. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71080. private _skyColor;
  71081. private _cloudColor;
  71082. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71083. updateShaderUniforms(): void;
  71084. skyColor: BABYLON.Color4;
  71085. cloudColor: BABYLON.Color4;
  71086. /**
  71087. * Serializes this cloud procedural texture
  71088. * @returns a serialized cloud procedural texture object
  71089. */
  71090. serialize(): any;
  71091. /**
  71092. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71093. * @param parsedTexture defines parsed texture data
  71094. * @param scene defines the current scene
  71095. * @param rootUrl defines the root URL containing cloud procedural texture information
  71096. * @returns a parsed Cloud Procedural BABYLON.Texture
  71097. */
  71098. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71099. }
  71100. }
  71101. declare module BABYLON {
  71102. /** @hidden */
  71103. export var fireProceduralTexturePixelShader: {
  71104. name: string;
  71105. shader: string;
  71106. };
  71107. }
  71108. declare module BABYLON {
  71109. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71110. private _time;
  71111. private _speed;
  71112. private _autoGenerateTime;
  71113. private _fireColors;
  71114. private _alphaThreshold;
  71115. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71116. updateShaderUniforms(): void;
  71117. render(useCameraPostProcess?: boolean): void;
  71118. static readonly PurpleFireColors: BABYLON.Color3[];
  71119. static readonly GreenFireColors: BABYLON.Color3[];
  71120. static readonly RedFireColors: BABYLON.Color3[];
  71121. static readonly BlueFireColors: BABYLON.Color3[];
  71122. autoGenerateTime: boolean;
  71123. fireColors: BABYLON.Color3[];
  71124. time: number;
  71125. speed: BABYLON.Vector2;
  71126. alphaThreshold: number;
  71127. /**
  71128. * Serializes this fire procedural texture
  71129. * @returns a serialized fire procedural texture object
  71130. */
  71131. serialize(): any;
  71132. /**
  71133. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71134. * @param parsedTexture defines parsed texture data
  71135. * @param scene defines the current scene
  71136. * @param rootUrl defines the root URL containing fire procedural texture information
  71137. * @returns a parsed Fire Procedural BABYLON.Texture
  71138. */
  71139. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71140. }
  71141. }
  71142. declare module BABYLON {
  71143. /** @hidden */
  71144. export var grassProceduralTexturePixelShader: {
  71145. name: string;
  71146. shader: string;
  71147. };
  71148. }
  71149. declare module BABYLON {
  71150. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71151. private _grassColors;
  71152. private _groundColor;
  71153. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71154. updateShaderUniforms(): void;
  71155. grassColors: BABYLON.Color3[];
  71156. groundColor: BABYLON.Color3;
  71157. /**
  71158. * Serializes this grass procedural texture
  71159. * @returns a serialized grass procedural texture object
  71160. */
  71161. serialize(): any;
  71162. /**
  71163. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71164. * @param parsedTexture defines parsed texture data
  71165. * @param scene defines the current scene
  71166. * @param rootUrl defines the root URL containing grass procedural texture information
  71167. * @returns a parsed Grass Procedural BABYLON.Texture
  71168. */
  71169. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71170. }
  71171. }
  71172. declare module BABYLON {
  71173. /** @hidden */
  71174. export var marbleProceduralTexturePixelShader: {
  71175. name: string;
  71176. shader: string;
  71177. };
  71178. }
  71179. declare module BABYLON {
  71180. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71181. private _numberOfTilesHeight;
  71182. private _numberOfTilesWidth;
  71183. private _amplitude;
  71184. private _jointColor;
  71185. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71186. updateShaderUniforms(): void;
  71187. numberOfTilesHeight: number;
  71188. amplitude: number;
  71189. numberOfTilesWidth: number;
  71190. jointColor: BABYLON.Color3;
  71191. /**
  71192. * Serializes this marble procedural texture
  71193. * @returns a serialized marble procedural texture object
  71194. */
  71195. serialize(): any;
  71196. /**
  71197. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71198. * @param parsedTexture defines parsed texture data
  71199. * @param scene defines the current scene
  71200. * @param rootUrl defines the root URL containing marble procedural texture information
  71201. * @returns a parsed Marble Procedural BABYLON.Texture
  71202. */
  71203. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71204. }
  71205. }
  71206. declare module BABYLON {
  71207. /** @hidden */
  71208. export var normalMapProceduralTexturePixelShader: {
  71209. name: string;
  71210. shader: string;
  71211. };
  71212. }
  71213. declare module BABYLON {
  71214. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71215. private _baseTexture;
  71216. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71217. updateShaderUniforms(): void;
  71218. render(useCameraPostProcess?: boolean): void;
  71219. resize(size: any, generateMipMaps: any): void;
  71220. baseTexture: BABYLON.Texture;
  71221. /**
  71222. * Serializes this normal map procedural texture
  71223. * @returns a serialized normal map procedural texture object
  71224. */
  71225. serialize(): any;
  71226. /**
  71227. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71228. * @param parsedTexture defines parsed texture data
  71229. * @param scene defines the current scene
  71230. * @param rootUrl defines the root URL containing normal map procedural texture information
  71231. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71232. */
  71233. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71234. }
  71235. }
  71236. declare module BABYLON {
  71237. /** @hidden */
  71238. export var perlinNoiseProceduralTexturePixelShader: {
  71239. name: string;
  71240. shader: string;
  71241. };
  71242. }
  71243. declare module BABYLON {
  71244. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71245. time: number;
  71246. timeScale: number;
  71247. translationSpeed: number;
  71248. private _currentTranslation;
  71249. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71250. updateShaderUniforms(): void;
  71251. render(useCameraPostProcess?: boolean): void;
  71252. resize(size: any, generateMipMaps: any): void;
  71253. /**
  71254. * Serializes this perlin noise procedural texture
  71255. * @returns a serialized perlin noise procedural texture object
  71256. */
  71257. serialize(): any;
  71258. /**
  71259. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71260. * @param parsedTexture defines parsed texture data
  71261. * @param scene defines the current scene
  71262. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71263. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71264. */
  71265. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71266. }
  71267. }
  71268. declare module BABYLON {
  71269. /** @hidden */
  71270. export var roadProceduralTexturePixelShader: {
  71271. name: string;
  71272. shader: string;
  71273. };
  71274. }
  71275. declare module BABYLON {
  71276. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71277. private _roadColor;
  71278. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71279. updateShaderUniforms(): void;
  71280. roadColor: BABYLON.Color3;
  71281. /**
  71282. * Serializes this road procedural texture
  71283. * @returns a serialized road procedural texture object
  71284. */
  71285. serialize(): any;
  71286. /**
  71287. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71288. * @param parsedTexture defines parsed texture data
  71289. * @param scene defines the current scene
  71290. * @param rootUrl defines the root URL containing road procedural texture information
  71291. * @returns a parsed Road Procedural BABYLON.Texture
  71292. */
  71293. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71294. }
  71295. }
  71296. declare module BABYLON {
  71297. /** @hidden */
  71298. export var starfieldProceduralTexturePixelShader: {
  71299. name: string;
  71300. shader: string;
  71301. };
  71302. }
  71303. declare module BABYLON {
  71304. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71305. private _time;
  71306. private _alpha;
  71307. private _beta;
  71308. private _zoom;
  71309. private _formuparam;
  71310. private _stepsize;
  71311. private _tile;
  71312. private _brightness;
  71313. private _darkmatter;
  71314. private _distfading;
  71315. private _saturation;
  71316. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71317. updateShaderUniforms(): void;
  71318. time: number;
  71319. alpha: number;
  71320. beta: number;
  71321. formuparam: number;
  71322. stepsize: number;
  71323. zoom: number;
  71324. tile: number;
  71325. brightness: number;
  71326. darkmatter: number;
  71327. distfading: number;
  71328. saturation: number;
  71329. /**
  71330. * Serializes this starfield procedural texture
  71331. * @returns a serialized starfield procedural texture object
  71332. */
  71333. serialize(): any;
  71334. /**
  71335. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71336. * @param parsedTexture defines parsed texture data
  71337. * @param scene defines the current scene
  71338. * @param rootUrl defines the root URL containing startfield procedural texture information
  71339. * @returns a parsed Starfield Procedural BABYLON.Texture
  71340. */
  71341. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71342. }
  71343. }
  71344. declare module BABYLON {
  71345. /** @hidden */
  71346. export var woodProceduralTexturePixelShader: {
  71347. name: string;
  71348. shader: string;
  71349. };
  71350. }
  71351. declare module BABYLON {
  71352. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71353. private _ampScale;
  71354. private _woodColor;
  71355. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71356. updateShaderUniforms(): void;
  71357. ampScale: number;
  71358. woodColor: BABYLON.Color3;
  71359. /**
  71360. * Serializes this wood procedural texture
  71361. * @returns a serialized wood procedural texture object
  71362. */
  71363. serialize(): any;
  71364. /**
  71365. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  71366. * @param parsedTexture defines parsed texture data
  71367. * @param scene defines the current scene
  71368. * @param rootUrl defines the root URL containing wood procedural texture information
  71369. * @returns a parsed Wood Procedural BABYLON.Texture
  71370. */
  71371. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  71372. }
  71373. }